Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (47.2k points)

I have a dimension with 3 categories and a measure of total sales count I want the ratio between one item of the category and the total

for example - I have a measure of fruit (Apple, Orange, Strawberry) I want the ratio of apple sales divided by total sales

Having trouble with the syntax

sum(([sales(fruit)='Apple']))/sum([sales])

 

1 Answer

0 votes
by (17.6k points)
  • You can use a conditional aggregation to do that. Basically, you just embed an if statement inside of the aggregate function like so:

SUM(IF [fruit] = 'Apple' THEN [sales] END) / SUM([sales])

  • The numerator SUM ignores all non-Apples, while the denominator includes all fruits.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Aug 23, 2021 in BI by dev_sk2311 (45k points)
0 votes
1 answer
asked Nov 21, 2019 in BI by Sammy (47.6k points)
0 votes
1 answer
asked Nov 3, 2019 in BI by Vaibhav Ameta (17.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...