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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Sum based on another value

Hi Team,

 

I have below screenshot for my data Table and Final output expected table.

 

Capture.PNG

 

 

Thanks,

KV's

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Anonymous,

I'd like to suggest you add a variable to summary these records and use the iterator function(sumx) on this variable to apply second aggregations.

Measure =
VAR summary =
    SUMMARIZE (
        Table,
        [Month],
        "Diff",
            LOOKUPVALUE ( RawTable[Target], RawTable[VALUES], [Month] )
                - LOOKUPVALUE ( RawTable[Target], RawTable[VALUES], "Total " & [Month] )
    )
RETURN
    SUMX ( summary, [Diff] )

The 'table' is a new calculate table with all month names, they are used as the category of table visual.

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @Anonymous,

I'd like to suggest you add a variable to summary these records and use the iterator function(sumx) on this variable to apply second aggregations.

Measure =
VAR summary =
    SUMMARIZE (
        Table,
        [Month],
        "Diff",
            LOOKUPVALUE ( RawTable[Target], RawTable[VALUES], [Month] )
                - LOOKUPVALUE ( RawTable[Target], RawTable[VALUES], "Total " & [Month] )
    )
RETURN
    SUMX ( summary, [Diff] )

The 'table' is a new calculate table with all month names, they are used as the category of table visual.

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous , Create a new column and use in visual with new measure suggested below

new column = SUBSTITUTE([Values] ,"Total ","")

 

 

measure =
var _1 = calculate(sum(Table[Target]) , filter(Table, search("Total",Table[value],,0)= 0)) - calculate(sum(Table[Target]) , filter(Table, search("Total",Table[value],,0)>0))
Var _2 = calculate(sum(Table[Target]) , filter(Table, search("Total",Table[value],,0)>0))
return
sumx(Values(Table[New column]), if(_2=0, 0, _1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.