Forum Discussion
Calculate Total and %
Hello, I am working on Power-Bi Dashboard to set up simple table using below. I need to show % of each product and total sales in a Month. I am having Table1. My output should be Table 2.
Here is what I am thinking.
- Create a measure to identify total sales in Month.
- DIVIDE [Actual sales by product] with [1].
For (1), I added thismeasure TotalSales = CALCULATE(SUM('Table'[Sales]),GROUPBY('Table','Table'[Month])). But this is not working.
If i am selecting only month column then , i see my measure is working. But If i add product it is not working. My Total sales column should display total sales in month having Month and Product columns in my view.
Any help or any better idea?
Table1. Data Available
| Month | Product | Sales |
| JUNE | A | 100 |
| JUNE | B | 120 |
| JUNE | C | 20 |
| JULY | A | 30 |
| JULY | B | 150 |
| JULY | C | 80 |
Table2. Data with New measures.
| Month | Product | Sales | Total Sales | % Sales |
| JUNE | A | 100 | 240 | 41.67% |
| JUNE | B | 120 | 240 | 50.00% |
| JUNE | C | 20 | 240 | 8.33% |
| JULY | A | 30 | 260 | 11.54% |
| JULY | B | 150 | 260 | 57.69% |
| JULY | C | 80 | 260 | 30.77% |
Thanks. I figured it out. CALCULATE(SUM('Table'[Sales]),GROUPBY('Table','Table'[Month]),ALL('Table')).
thats it. - I need to tell to DAX exclude all filters. so ALL() did the trick.
2 Replies
- masitbahaRegular Visitor
How about using 'Matrix' instead of 'Table'?
- mrvamsidharHelper I
Thanks. I figured it out. CALCULATE(SUM('Table'[Sales]),GROUPBY('Table','Table'[Month]),ALL('Table')).
thats it. - I need to tell to DAX exclude all filters. so ALL() did the trick.