Forum Discussion
Sum column values based on slicers
Hi all,
I am trying to create a mesure where I need to sum only the column (Total) values which are based on the slicer filters. There are two slicers: ID (from the fact table) and a Date range (a dimension table). Secondly, if there is no option selected from the slicer then all values should be summed up.
I have tried to use SUMX(DISTINCT(DatassetFact[Total]), DatassetFact[Total]) which is working fine for the distinct values but we need to sum all values that are filtered based on ID and Date range. Whereas Sum(DatassetFact[Total]) provide sum of all the values in the column not based on the slicer selection.
Solution mention in the post (https://community.powerbi.com/t5/Desktop/Sum-column-values-based-on-slicers/m-p/3010169/highlight/true#) is fulfilling the requirement but what if same user have repeated totals for the same date then in case only one TOTAL value should be consider to sum.
for example, for user having ID =6 and 12 have data like below where "...." represents some other columns having unique values :
6 A 7.12.2022 320 ... ... ... ... .. .. .. ..
6 A 7.12.2022 320 ... ... ... ... .. .. .. ..
12 C 7.12.2022 400 ... ... ... ... .. .. .. ..
12 C 7.12.2022 400 ... ... ... ... .. .. .. ..
Thanks in advance!
1 Reply
- amitchandakSuper User
amre , You have to create a measure
Sum(DatassetFact[Total])
or
calculate(Sum(DatassetFact[Total]) , allselected() )
A calculated column can not take slicer value. So you have to use measure