Forum Discussion

julienvdc's avatar
julienvdc
Icon for Helper III rankHelper III
5 years ago
Solved

Drilling down a chart using a slicer

Hey there,   I am displaying data in a stacked-column chart that can either be viewed by countries, or if we drill down, by cities. I have drill-down activated on the chart, and so if I click on o...
  • Icey's avatar
    5 years ago

    Hi julienvdc ,

     

    Please check:

     

    Sample data:

     

    Country City Product Value
    Country1 City1-1 Product1 1
    Country1 City1-2 Product1 2
    Country1 City1-3 Product1 3
    Country1 City1-4 Product1 4
    Country2 City2-1 Product1 5
    Country2 City2-2 Product1 6
    Country2 City2-3 Product1 7
    Country2 City2-4 Product1 8
    Country3 City3-1 Product1 9
    Country3 City3-2 Product1 10
    Country3 City3-3 Product1 11
    Country3 City3-4 Product1 12
    Country1 City1-1 Product2 12
    Country1 City1-2 Product2 11
    Country1 City1-3 Product2 10
    Country1 City1-4 Product2 9
    Country2 City2-1 Product2 8
    Country2 City2-2 Product2 7
    Country2 City2-3 Product2 6
    Country2 City2-4 Product2 5
    Country3 City3-1 Product2 4
    Country3 City3-2 Product2 3
    Country3 City3-3 Product2 2
    Country3 City3-4 Product2 1

     

     

    1. Create a x-axis table.

    X axis = 
    VAR Country_ = DISTINCT('Table'[Country])
    VAR City_ = DISTINCT('Table'[City])
    RETURN UNION(Country_,City_)

     

    2. Create relationships between "Table" and "X axis" table.

     

    3. Create a measure.

    Measure =
    IF (
        ISFILTERED ( 'Table'[Country] ),
        CALCULATE (
            SUM ( 'Table'[Value] ),
            USERELATIONSHIP ( 'Table'[City], 'X axis'[Country] )
        ),
        SUM ( 'Table'[Value] )
    )
    

     

    4. Create a Stacked column chart visual.

     

    5. Test.

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.