Forum Discussion

karthikmiriyala's avatar
karthikmiriyala
Frequent Visitor
3 years ago
Solved

Creating a table with values changing respective with what if parameter.

I am creating a Dashboard with two what-if parameters. Able to create a Scatter plot with Quadrants, changing with respective what-if parameters As shown in the picture.    The Quadrants will...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi karthikmiriyala,

    You can create a new table with two modes to use in formula change calculation mode:

    SwitchMode = {"Mean","Median"}

    Here are the dynamic measure formulas based on two what-if parameter tables, Quadrant group and mode slicer.

    petalLength = 
    VAR selected =
        SELECTEDVALUE ( SwitchMode[Value] )
    VAR currQuadrant =
        MAX ( 'Table'[Quadrant] )
    VAR currpLength =
        MAX ( iris[petal_length] )
    VAR currpWidth =
        MAX ( iris[petal_width] )
    VAR c1 =
        IF ( currQuadrant <= 2, currpLength <= [spLength], currpLength > [spLength] )
    VAR c2 =
        IF ( currQuadrant IN { 1, 3 }, currpWidth <= [spWidth], currpWidth > [spWidth] )
    RETURN
        CALCULATE (
            IF (
                selected = "Mean",
                AVERAGE ( iris[petal_length] ),
                IF ( selected = "Median", MEDIAN ( iris[petal_length] ) )
            ),
            FILTER ( ALLSELECTED ( iris ), c1 && c2 )
        )+0
    
    petalWidth = 
    VAR selected =
        SELECTEDVALUE ( SwitchMode[Value] )
    VAR currQuadrant =
        MAX ( 'Table'[Quadrant] )
    VAR currpLength =
        MAX ( iris[petal_length] )
    VAR currpWidth =
        MAX ( iris[petal_width] )
    VAR c1 =
        IF ( currQuadrant <= 2, currpLength <= [spLength], currpLength > [spLength] )
    VAR c2 =
        IF ( currQuadrant IN { 1, 3 }, currpWidth <= [spWidth], currpWidth > [spWidth] )
    RETURN
        CALCULATE (
            IF (
                selected = "Mean",
                AVERAGE ( iris[petal_width] ),
                IF ( selected = "Median", MEDIAN ( iris[petal_width] ) )
            ),
            FILTER ( ALLSELECTED ( iris ), c1 && c2 )
        )+0
    
    sepalLength = 
    VAR selected =
        SELECTEDVALUE ( SwitchMode[Value] )
    VAR currQuadrant =
        MAX ( 'Table'[Quadrant] )
    VAR currspLength =
        MAX ( iris[sepal_length] )
    VAR currspWidth =
        MAX ( iris[sepal_width] )
    VAR c1 =
        IF ( currQuadrant <= 2, currspLength <= [spLength], currspLength > [spLength] )
    VAR c2 =
        IF ( currQuadrant IN { 1, 3 }, currspWidth <= [spWidth], currspWidth > [spWidth] )
    RETURN
        CALCULATE (
            IF (
                selected = "Mean",
                AVERAGE ( iris[sepal_length] ),
                IF ( selected = "Median", MEDIAN ( iris[sepal_length] ) )
            ),
            FILTER ( ALLSELECTED ( iris ),  c1 && c2  )
        )+0
    
    sepalWidth = 
    VAR selected =
        SELECTEDVALUE ( SwitchMode[Value] )
    VAR currQuadrant =
        MAX ( 'Table'[Quadrant] )
    VAR currspLength =
        MAX ( iris[sepal_length] )
    VAR currspWidth =
        MAX ( iris[sepal_width] )
    VAR c1 =
        IF ( currQuadrant <= 2, currspLength <= [spLength], currspLength > [spLength] )
    VAR c2 =
        IF ( currQuadrant IN { 1, 3 }, currspWidth <= [spWidth], currspWidth > [spWidth] )
    RETURN
        CALCULATE (
            IF (
                selected = "Mean",
                AVERAGE ( iris[sepal_width] ),
                IF ( selected = "Median", MEDIAN ( iris[sepal_width] ) )
            ),
            FILTER ( ALLSELECTED ( iris ),  c1 && c2  )
        )+0

    Regards,

    Xiaoxin Sheng