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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

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
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.