0 votes
1 view
in BI by (44.9k 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 (16.7k 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 Nov 21, 2019 in BI by Sammy (47.8k points)
0 votes
1 answer
asked Nov 3, 2019 in BI by Vaibhav Ameta (16.7k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...