Forum Discussion

DannyPhan's avatar
DannyPhan
New Member
1 year ago

Wrong total for sub categories

I'm new to Power BI, can anyone help me fix this Measure: 

Test =
var prev_index = MAX(version_code[index])-1
var prev_ver = LOOKUPVALUE(version_code[ver], version_code[index], prev_index, "")
RETURN
CALCULATE(SUM('Version'[NC_TT_TN]), FILTER(ALLEXCEPT('Version', 'Version'[MTC]), 'Version'[Ver] = prev_ver))

 

BF =Before, AF = After. I want to take the results from column BF and this display them in the column AF in order to calculate the variance.

3 Replies

  • Hi DannyPhan - I suggest making adjustments to the prev_index logic and filtering to ensure it looks for the previous row based on your custom index logic. Please use the updated measure 

     

    Test =
    VAR current_index = MAX(version_code[index])
    VAR prev_index = current_index - 1
    VAR prev_ver = LOOKUPVALUE(version_code[ver], version_code[index], prev_index)
    RETURN
    CALCULATE(
    SUM('Version'[NC_TT_TN]),
    FILTER(
    ALLEXCEPT('Version', 'Version'[MTC]),
    'Version'[Ver] = prev_ver
    )
    )

     

    Hope this works to display the expected output.

    • DannyPhan's avatar
      DannyPhan
      New Member

      Thanks for your answer rajendraongole1 . But it still display the same result as before. Noted that the model has parent child hierachy.