Forum Discussion
Sum in different hierarchy levels
- Anonymous2 years ago
Thanks for the reply from shafiz_p , please allow me to provide another insight:
Hi G4analytic ,I created some data:
Here are the steps you can follow:
1. Create measure.
Store_measure = SUMX('table1',[total value])City_measure = var _select=SELECTEDVALUE('SlicerTable'[Slicer]) RETURN IF( _select="City",SUMX(FILTER(ALL('table1'),[City] in SELECTCOLUMNS('table1',"test",'table1'[City])),[total value]) ,SUMX(FILTER(ALL('table1'),[Country]=MAX('table1'[Country])),[total value]))Country_measure = SUMX(FILTER(ALL('table1'),[Country] in SELECTCOLUMNS('table1',"test",'table1'[Country])),[total value])2. Result:
If dax gets results that don't match your expected results, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks for the reply from shafiz_p , please allow me to provide another insight:
Hi G4analytic ,
I created some data:
Here are the steps you can follow:
1. Create measure.
Store_measure =
SUMX('table1',[total value])City_measure =
var _select=SELECTEDVALUE('SlicerTable'[Slicer])
RETURN
IF(
_select="City",SUMX(FILTER(ALL('table1'),[City] in SELECTCOLUMNS('table1',"test",'table1'[City])),[total value])
,SUMX(FILTER(ALL('table1'),[Country]=MAX('table1'[Country])),[total value]))Country_measure =
SUMX(FILTER(ALL('table1'),[Country] in SELECTCOLUMNS('table1',"test",'table1'[Country])),[total value])
2. Result:
If dax gets results that don't match your expected results, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly