Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
DCZ
New Member

Comparison field does not update when I SUM a value.

I would love some help on figuring out this issue that has been bugging me for days.

I have 3 User IDs comparing the current number with the average number.

User IDAverage NumCurrent NumComparison
1200150Below Avg
1200150Below Avg
2200300Above Avg
3100200Above Avg

In Power BI desktop I SUM(Current Num) and the table will look like this.

User IDAverage NumCurrent NumComparison
1200300Below Avg
2200300Above Avg
3100200Above Avg

 

The User ID, Average Num, and Current Num updated. Comparison did not update, as, it should be Above instead of Below.

The Comparison column was created using DAX if Current Num > Average Num then Above Avg and if Current Num < Average Num then Below Avg.

 

I also want to note that there are many columns in the table and not just User ID.

1 ACCEPTED SOLUTION
v-weiyan1-msft
Community Support
Community Support

Hi @DCZ ,

 

@amustafa nice method! Thank you, for your quick response and the solution provided.
And you can also consider using the following code to create a Measure.

Comparison = 
VAR Cnt =
    CALCULATE (
        COUNT ( 'Table'[User ID] ),
        FILTER ( 'Table', 'Table'[User ID] = MAX ( 'Table'[User ID] ) )
    )
VAR Sum_Num =
    CALCULATE (
        SUM ( 'Table'[Average Num] ),
        ALLEXCEPT ( 'Table', 'Table'[User ID] )
    )
VAR Avg_Num =
    IF ( Cnt > 1, MAX ( 'Table'[Average Num] ), Sum_Num )
VAR Cur_Num =
    CALCULATE (
        SUM ( 'Table'[Current Num] ),
        ALLEXCEPT ( 'Table', 'Table'[User ID] )
    )
RETURN
    IF ( Cur_Num > Avg_Num, "Above Avg", "Below Avg" )

Result is as below.

vweiyan1msft_0-1708419848015.png


Best Regards,
Yulia Yan


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

View solution in original post

3 REPLIES 3
v-weiyan1-msft
Community Support
Community Support

Hi @DCZ ,

 

@amustafa nice method! Thank you, for your quick response and the solution provided.
And you can also consider using the following code to create a Measure.

Comparison = 
VAR Cnt =
    CALCULATE (
        COUNT ( 'Table'[User ID] ),
        FILTER ( 'Table', 'Table'[User ID] = MAX ( 'Table'[User ID] ) )
    )
VAR Sum_Num =
    CALCULATE (
        SUM ( 'Table'[Average Num] ),
        ALLEXCEPT ( 'Table', 'Table'[User ID] )
    )
VAR Avg_Num =
    IF ( Cnt > 1, MAX ( 'Table'[Average Num] ), Sum_Num )
VAR Cur_Num =
    CALCULATE (
        SUM ( 'Table'[Current Num] ),
        ALLEXCEPT ( 'Table', 'Table'[User ID] )
    )
RETURN
    IF ( Cur_Num > Avg_Num, "Above Avg", "Below Avg" )

Result is as below.

vweiyan1msft_0-1708419848015.png


Best Regards,
Yulia Yan


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

amustafa
Solution Sage
Solution Sage

try this...

 

ComparisonStatus = 
VAR CurrentNum = SUM(Table1[Current Num])
VAR AverageNum = AVERAGE(Table1[Average Num])
RETURN
    IF(
        HASONEVALUE(Table1[User ID]),
        IF(
            CurrentNum > AverageNum, "Above Average",
            IF(
                CurrentNum = AverageNum, "Equal",
                "Below Average"
            )
        ),
        BLANK() -- This is for the total row where multiple User IDs are aggregated
    )

 

amustafa_0-1706854637806.png

 

If I answered your question, please mark this thread as accepted and Thums Up!
Follow me on LinkedIn:
https://www.linkedin.com/in/mustafa-ali-70133451/

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for replying! I tried the code and the data is blank for me on each row. There are around 10 columns with other IDs and Dates. I tried removing HASONEVALUE and it is still not working for me.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors