Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Measure not displaying correct total value

Hi all,   I created this measure:   BonusTestM = VAR BonusMin = SELECTEDVALUE('BonusValue'[BonusMin]) VAR BonusMax = SELECTEDVALUE('BonusValue'[BonusMax]) VAR BonusValueMin = SELECTEDVALUE('Bon...
  • v-jingzhang's avatar
    5 years ago

    Hi Anonymous 

     

    You can use two measures to achieve it. Put the first single measure in the second total measure, just like below:

    BonusTestM = 
    VAR BonusMin = SELECTEDVALUE('BonusValue'[BonusMin])
    VAR BonusMax = SELECTEDVALUE('BonusValue'[BonusMax])
    VAR BonusValueMin = SELECTEDVALUE('BonusValue'[BonusValueMin])
    VAR BonusValueMax = SELECTEDVALUE('BonusValue'[BonusValueMax])
    VAR SumOfValue = SUM(Income[Value])
    RETURN
    SWITCH(
    TRUE(),
    SumOfValue < BonusMin, 0,
    SumOfValue < BonusMax, BonusValueMin,
    BonusValueMax
    )
    BonusTestTotal = SUMX(VALUES(Income[Value]),[BonusTestM])

    Measures are calculated based on the context they are in. Other columns you put in the table visual will influence the context of measures, along with the filters outside.

     

    In this case, with VALUES(Income[Value]) in the total measure, it will work when all the Values are distinct. If there are duplicate Income[Value], it may not work because VALUES() always returns the distinct values from a column.

     

    Kindly let me know if this helps.
    Community Support Team _ Jing Zhang
    If this post helps, please consider Accept it as the solution to help other members find it.