Forum Discussion

Ruz's avatar
Ruz
Regular Visitor
2 years ago
Solved

Create a variable chart that calculates ratios and plots the chart

Hi,   I am trying to create a variable chart where it will show the ratio of Column "A" and Column "B". Except i need A and B to be variable selected from 15 columns, is that possible?   i.e. I h...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Ruz ,

    Here is my sample data:

    And I build two table to create two slicers for numerator and denominator:



    Use this DAX to create a new measure:

    Measure = 
    VAR Numerator_SUM = 
    CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            'Table',
            'Table'[Column] = SELECTEDVALUE('numerator'[numerator])
        )
    )
    VAR Denominator_SUM = 
    CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            'Table',
            'Table'[Column] = SELECTEDVALUE('denominator'[denominator])
        )
    )
    RETURN
    DIVIDE(Numerator_SUM, Denominator_SUM)

    Put this measure into the visual, and the final output is below:

     

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