Forum Discussion

Dominik82's avatar
Dominik82
Frequent Visitor
2 years ago

Measure calculate difference from line value to total value

Hi all,

 

currently I'm building a report on an existing dataset and I can use only measures for some calculations.

Now I'm facing on a problem to calculate the differnece from line value to total value.

 

At first I've a measure which calculates the average of a column with some filters.

 

 

 

 

Average = 
    VAR Temp =
        CALCULATE(
            SUM(Table[Probability])
            ,REMOVEFILTERS(Table[Product])
        )

    VAR AmountID =
        DISTINCTCOUNT(Table[ID])

    RETURN
        IF(AmountProjects = 0, BLANK(), (Temp / AmountID) / 100)

 

 

 

 

Works well, my table in the report looks like this:

PhaseAmountAverageDifference
1422,50% 
2130,00% 
31100,00% 
41100,00% 
Total745,71%

 

 

My problem is, that I don't know how I can calculate the difference from the column average per line to the total value of column average.
Maybe someone has a hint how to solve this?


Thanks in advance,
Dominik

2 Replies

  • Dominik82 , Based on what I see on visual, it should be like , assuming Amount is a measure

     

    divide([Amount], calculate([Amount], removefilters(Table[Phase]) ) )

    Or use a visual calculation template for % of the total

     

    Master Visual Calculations in Power BI- February 2024 Update RUNNINGSUM, RANGE, MOVINGAVERAGE, COLLAPSE, COLLAPSEALL, EXPAND, EXPANDALL, FIRST, LAST, PREVIOUS, and NEXT
    https://www.youtube.com/watch?v=bKD9T0EWgQo&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from amitchandak , please allow me to provide another insight: 

    Hi  Dominik82 ,

     

    Are you referring to comparing the Total of 45.71% for [Average] with each row’s [Average]?

    You can create a measure to calculate the result of Total 45.71%, and then subtract it from [Average] for comparison. I’m not quite clear on how the Total of 45.71% is calculated. If it’s convenient for you, could you explain the logic behind calculating the Total value and share sample data and expected output in a table format? Alternatively, if you could provide an example pbix file with sensitive data removed, we could assist you better.

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.