Forum Discussion

G4analytic's avatar
G4analytic
Regular Visitor
1 year ago
Solved

Sum in different hierarchy levels

Hello community, I have been trying to create a table with 3 Slicers:     This is the table (as i want to see):     My problem is: i have created 3 measures "Store","City" and "Cou...
  • Anonymous's avatar
    Anonymous
    1 year 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