Forum Discussion
Sum by Individual Selection and Sum by Group
- 4 years ago
@kamil947, apologies. I misread the part that you wanted the "Sum of Group" in the other Card.
Although @Kevin_Harper has provided a very good output in terms of Calculated Columns, there is a challenge with using this for the output as evident below. The total of the Calculated Column totals the amounts at the row level and therefore can overstate the actual output.
I recommend using a Measure as per below which provides the total amount of 26 when nothing is selected but also achieves the group subtotal in the Card visual itself.
The Measure is as follows:
Measure = SUMX ( VALUES ( tableFood[Group] ) , CALCULATE ( SUM ( tableFood[Amount] ) , ALLEXCEPT ( 'tableFood' , tableFood[Group] ) ) )All the best.
Hi kamil947 ,
You will need to create an independent slicer table.
slicer = DISTINCT('Table'[Food])
Use this table as slicer and then create two measures as below for selected food and group.
food_amount = CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Food]=SELECTEDVALUE('slicer'[Food])))
group_amount =
var _group = CALCULATE(MAX('Table'[Group]),FILTER(ALL('Table'),'Table'[Food]=SELECTEDVALUE(slicer[Food])))
return
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Group]=_group))
Result would be shown as below.
Best Regards,
Jay