Forum Discussion

barbforsman's avatar
barbforsman
Resolver I
8 years ago
Solved

Measure does not total

I have a measure that finds the smallest bandwidth and longest term for a quote and displays the MRC.  But the MRC does not total in a matrix. This is the measure I'm using: MinBWMaxT = var minB...
  • barbforsman's avatar
    barbforsman
    8 years ago

    William Rodriguez gave me this answer that works:

     

    VAR StandardEquation =
        VAR MinBW = MIN( Table1[BW] )
        VAR MaxT = MAX( Table1[Term] )
        RETURN
            CALCULATE(
                SUM( Table1[MRC] ) ,
                Table1[BW] = MinBW ,
                Table1[Term] = MaxT
            )
    VAR Total_Equation =
        SUMX(
            Table1 ,
                VAR ONE =
                    CALCULATE(
                        MIN ( Table1[BW] ) ,
                        FILTER(
                            Table1 ,
                            Table1[Quote Number] = EARLIER( Table1[Quote Number] )
                        )
                    )
                VAR TWO =
                    CALCULATE(
                        MAX ( Table1[Term] ) ,
                        FILTER(
                            Table1 ,
                            Table1[Quote Number] = EARLIER( Table1[Quote Number] )
                        )
                    )
                VAR EQUATION =
                    IF (
                        Table1[BW] = ONE && Table1[TERM] = TWO ,
                        Table1[MRC]
                    )
                RETURN EQUATION
        )
    VAR GRANULARITY_CHECK =
        VAR YEAR = SELECTEDVALUE( 'Calendar'[Year] )
        VAR TOTAL_TYPE = COUNTROWS( VALUES( 'Calendar'[Year] ) )
        VAR Total_Indicator =
            CALCULATE(
                COUNTROWS( Table1 ) ,
                'Calendar'[Year] = YEAR ,
                ALLSELECTED(Table1 )
            )
        RETURN
            COUNTROWS( Table1 ) = Total_Indicator || ( TOTAL_TYPE > 1 )
    RETURN
        IF(
            GRANULARITY_CHECK = TRUE() ,
            Total_Equation ,
            StandardEquation
        )