Forum Discussion
Assistance Needed with DAX Calculation
Hi all,
I'm new to Power Bi and I'm having an issue with a calculation. I am trying to calculate the share of sales an item holds. This is done by dividing the number of items sold by the Total Sales of a selected period. Using the sample table below:
Total Sales = 14,700 (2500+9000+1500+1700)
Sales Share (Soft Drink) = Qty / Total Sales
= 100 / 14700 = 0.006802721
| Description | Qty | Total Sales | Sales Share |
| Soft Drink | 100 | 2500 | 0.006802721 |
| Pizza | 57 | 9000 | 0.003877551 |
| Burger | 25 | 1500 | 0.00170068 |
| Sandwich | 17 | 1700 | 0.001156463 |
Best regards,
Stephanie.
Hi 5B ,
How about this:
Here the DAX code for the measure:
Measure = DIVIDE ( SUM ( 'Table'[Qty] ), CALCULATE ( SUM ( 'Table'[Total Sales] ), ALL ( 'Table' ) ) )Let me know if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
3 Replies
- tackytechtomMost Valuable Professional
Hi 5B ,
How about this:
Here the DAX code for the measure:
Measure = DIVIDE ( SUM ( 'Table'[Qty] ), CALCULATE ( SUM ( 'Table'[Total Sales] ), ALL ( 'Table' ) ) )Let me know if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/- 5BRegular Visitor
Hey Tom,
It worked! Thank you.
I added in
FILTER(ALL('Table'), 'Table'[Date] IN VALUES('Table'[Date]))
Really appreciate it!