Forum Discussion
Power BI Table Group Total
I have mock dataset looks like below.
On my visualization, I have two problems:
1) I am trying to show the total sales by group. - called "group total". But on my dataset, I have Item Code called "/return". I do not want to list "/return" on my visualization. So I filtered it out through filters.
I created measure called "group total" with the following dax formula :
group total = CALCULATE(SUM(Table1[Total Sales]),ALLEXCEPT(Table1,Table1[Group],Table1[Date]))
2. I want to add a column called "return" that sums all the "/return". So same group will show same amount of "return", just like "group total".
I created measure "return" just to show you what I want.
return = Calculate(Sum(Table1[Total Sales]),Filter(Table1,Find("/",Table1[Item code], ,0)<>0))
What I want eventually is something like this.
I hope I described my problem clear enough.
I would appreciate any help!
Hi Anonymous ,
I have modified my formula as below, you could have a try:
Measure = CALCULATE(SUM(Table1[Total Sales]),FILTER(ALL('Table1'),'Table1'[Group]=MAX('Table1'[Group])&&'Table1'[item code]<>"/return"))Measure 2 = CALCULATE(SUM(Table1[Total Sales]),FILTER(ALLEXCEPT(Table1,Table1[Group],Table1[Date]),'Table1'[item code]="/return"))
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He
3 Replies
- v-danhe-msftMicrosoft Employee
Hi Anonymous ,
Based on my test, you could refer to below formula:
Measure = SUMX(CALCULATETABLE('Table1',FILTER(ALL(Table1),'Table1'[Group]=MAX('Table1'[Group]))),CALCULATE(ABS(SUM(Table1[Total Sales]))))Measure 2 = CALCULATE(SUM(Table1[Total Sales]),FILTER(ALLEXCEPT(Table1,Table1[Group]),'Table1'[item code]="/return"))
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He
- AnonymousNot applicable
Hi Daniel,
Your solution has two problems.
1. "Measure" doesn't total up correctly. It should be 1700 (800+600+300) for group A.2. "Measure2" doesn't reflect the date slicer. If I filter to February, Measure 2 still has values. But if you look at the dataset, February doesn't have "/return" value.
- v-danhe-msftMicrosoft Employee
Hi Anonymous ,
I have modified my formula as below, you could have a try:
Measure = CALCULATE(SUM(Table1[Total Sales]),FILTER(ALL('Table1'),'Table1'[Group]=MAX('Table1'[Group])&&'Table1'[item code]<>"/return"))Measure 2 = CALCULATE(SUM(Table1[Total Sales]),FILTER(ALLEXCEPT(Table1,Table1[Group],Table1[Date]),'Table1'[item code]="/return"))
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He