Forum Discussion

mh20221111's avatar
mh20221111
Icon for Helper II rankHelper II
1 year ago
Solved

Adjusting the Total Range Based on User-Selected Parameter Values

There are two columns and three measures as shown in the figure. When the column 'size' is sorted in descending order, there is always one size for which the result of the formula set for measure 1 i...
  • OwenAuger's avatar
    OwenAuger
    1 year ago

    Thanks mh20221111 ğŸ™‚

    I'm assuming that

    • Parameter Value is a measure returning the parameter value.
    • Measure1 and Measure2 need to be evaluated for each Commodity/SIZE then summed (but easily adjusted if you just need to evaluate per SIZE then sum).

    This would then be the Sum Measure1 measure:

    Sum Measure1 = 
    VAR ParameterValue = [Parameter Value]
    VAR Result =
        SUMX (
            SUMMARIZE ( 'Table', 'Table'[Commodity], 'Table'[SIZE] ),
            VAR Measure3Value = [Measure3]
            RETURN
                IF (
                    AND ( Measure3Value >= 0, Measure3Value <= ParameterValue ),
                    [Measure1]
                )
        )
    RETURN
        Result

     

    If Measure1 and Measure2 produce the same result whether summed per Commodity/SIZE or evaluated as-is, you could write this:

    Sum Measure1 v2 = 
    VAR ParameterValue = [Parameter Value]
    VAR CommoditySIZE =
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[Commodity], 'Table'[SIZE] ),
            VAR Measure3Value = [Measure3]
            RETURN
                AND ( Measure3Value >= 0, Measure3Value <= ParameterValue )
        )
    VAR Result =
        CALCULATE (
            [Measure1],
            CommoditySIZE
        )
    RETURN
        Result

    You can change the SUMMARIZE expression to VALUES ( 'Table'[SIZE] ) if you don't need Commodity to be included.

     

    Does this work for you?