<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ABAP CDS View Default Aggregation #FORMULA in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192807#M1980940</link>
    <description>&lt;P&gt;As your definition says&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;1 as percentage&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;there is no surprise that you see 1 for all rows&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.3/en-US/fc596c7cb366440a84f9d41f7710d6ca.html#d21532e48"&gt;Documentation for @AnalyticsDetails.query.formula&lt;/A&gt; says: &lt;/P&gt;&lt;P&gt;&lt;EM&gt;This annotation allows you to specify the formula expression, which cannot be expressed as an SQL formula (operands required from the element list of the view). Only numerical values (measures) can be used as operands.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Scope: #ELEMEN&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Evaluation Runtime (Engine): This annotation will be interpreted as a formula by the analytic manager.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The formula for the annotation will not be evaluated for queries not going through the analytical manager -- which way do you test the view?&lt;/P&gt;&lt;P&gt;You could move the formula to a SQL expression and remove the  @AnalyticsDetails.query.formula annotation -- and then of course you would need to deal with zero value for the divisor. The best way could be here a UNION ALL with WHERE conditions on QtaOrdered field in both branches (one branch WHERE QtaOrdered &amp;lt;&amp;gt; 0 and another WHERE QtoOrdered = 0 )&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jun 2020 09:43:10 GMT</pubDate>
    <dc:creator>gasparerdelyi</dc:creator>
    <dc:date>2020-06-23T09:43:10Z</dc:date>
    <item>
      <title>ABAP CDS View Default Aggregation #FORMULA</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192806#M1980939</link>
      <description>&lt;P&gt;Dear SAP consultants,&lt;/P&gt;
  &lt;P&gt;I am trying to use the ' @DefaultAggregation: #FORMULA ' aggregation in a CDS View but I cannot make it work.&lt;/P&gt;
  &lt;P&gt;The business requirement is the following: We have the quantity ordered and the quantity sold and we have to provide the percentage of the goods sold out of the ordered quantity.&lt;/P&gt;
  &lt;P&gt;For the Quantity Ordered and Quantity Sold I used '@DefaultAggregation: #SUM' and for the calculated column I used the below code snippet taken from another post:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;@Aggregation.default:#FORMULA
@AnalyticsDetails.query.formula:'NDIV0(QtaSold / QtaOrdered ) * 100'
@AnalyticsDetails.query.decimals:2
1 as Percentage&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;While testing the CDS, I am getting '1' across the whole output for the calculated column.&lt;/P&gt;
  &lt;P&gt;Could you please advise what am I missing?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 08:06:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192806#M1980939</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-06-23T08:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Default Aggregation #FORMULA</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192807#M1980940</link>
      <description>&lt;P&gt;As your definition says&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;1 as percentage&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;there is no surprise that you see 1 for all rows&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.3/en-US/fc596c7cb366440a84f9d41f7710d6ca.html#d21532e48"&gt;Documentation for @AnalyticsDetails.query.formula&lt;/A&gt; says: &lt;/P&gt;&lt;P&gt;&lt;EM&gt;This annotation allows you to specify the formula expression, which cannot be expressed as an SQL formula (operands required from the element list of the view). Only numerical values (measures) can be used as operands.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Scope: #ELEMEN&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Evaluation Runtime (Engine): This annotation will be interpreted as a formula by the analytic manager.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The formula for the annotation will not be evaluated for queries not going through the analytical manager -- which way do you test the view?&lt;/P&gt;&lt;P&gt;You could move the formula to a SQL expression and remove the  @AnalyticsDetails.query.formula annotation -- and then of course you would need to deal with zero value for the divisor. The best way could be here a UNION ALL with WHERE conditions on QtaOrdered field in both branches (one branch WHERE QtaOrdered &amp;lt;&amp;gt; 0 and another WHERE QtoOrdered = 0 )&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 09:43:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192807#M1980940</guid>
      <dc:creator>gasparerdelyi</dc:creator>
      <dc:date>2020-06-23T09:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Default Aggregation #FORMULA</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192808#M1980941</link>
      <description>&lt;P&gt;Hi Gaspar,&lt;/P&gt;&lt;P&gt;Thank you for your reply!&lt;/P&gt;&lt;P&gt;Actually the formula was ok but I`ve just learned that you cannot test an Analytical CDS by just running it with F8. You have to use T-Code RSRT in order to see the Formula aggregated values correctly.&lt;/P&gt;&lt;P&gt;When running the transaction you need to add "2C" in from of the sqlViewName of your CDS.&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2020 12:05:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192808#M1980941</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-07-02T12:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP CDS View Default Aggregation #FORMULA</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192809#M1980942</link>
      <description>&lt;P&gt;To be precise, you can test the CDS view with F8 / Data Preview but that is not going through the Analytical Manager at all.&lt;/P&gt;&lt;P&gt;If you would like to test via the Analytical Manager from SAP GUI, then you can use RSRTS_ODP_DIS on ODP provider / cube level and RSRT on query level.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 21:05:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-cds-view-default-aggregation-formula/m-p/12192809#M1980942</guid>
      <dc:creator>gasparerdelyi</dc:creator>
      <dc:date>2020-07-03T21:05:49Z</dc:date>
    </item>
  </channel>
</rss>

