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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Help subtracting a measure from column

Hi everyone,

 

I am having trouble subtracting a measure from a column in directquery mode. 

 

cWQXRcv

 

I am trying to subtract Column 3 from TaktDiff which is a measure. The issue is that TaktDiff is a summation of values based on Column Serial. Column 3 is determined by an if statement in a separate table that is based on the values in Column Tier 2. Since one is a measure and the other is a calculated column, I cannot figure out a way to find the difference between them and still preserve the summation of TaktDiff.

 

I have been working on this for a couple hours now and I am pretty stuck. I am sure I am missing something obvious.

 

Any help would be appreciated.

1 ACCEPTED SOLUTION

@Anonymous you have to be specific which solution you tried and not worked, you have few awesome people replied to your post, be more specific. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

9 REPLIES 9
S184019
Advocate III
Advocate III

I am trying to build a table like the one below: 

SalesPersonIDRegionIDWeekBaseline SalesSales VarianceRunning Variance

1

16/27/2045,00045,128128128
117/4/2045,00044,872-1280
117/11/2045,00046,1941,1941,194
126/27/2045,00049,2204,2205414
216/27/2038,00038158158158

 

I am unsure how to go about calculating the running variance.  The assumption is, I can just take the baseline sales and subtract the sales and that gives us the variance, but then adding that variance doesn't work when we get to the next region or the next sales person.  

I have built a summary table to calculate the baseline sales which is the average sales value in a given time frame before 5/30/20 regardless of the region. 

I am able to calculate a variance, but I need to be able to calculate that running variance by salesperson.  It isn't as simple as;


Running Variance = SUMX(SUMMARIZE('table1','table1'[salespersonID],

"_1",CALCULATE(SUM('table1'[Sales]),'table1'[Baseline Vol Flag]=1), -- This part creates the baseline 
"_2",CALCULATE(SUM('table1'[Sales]),'table1'[Baseline Vol Flag]=1) - SUM('table1'[Sales]), -- This calculates the variance
[_1]-[_2])
 
Notice how the [_2] doesn't take into consideration the previous variance. 
Ideally what I would like is Sales - Baseline + Previous Variance = Running Variance
 
Any help?
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try using this

Measure = 
SUMX( 'Table', [TaktDiff] - 'Table'[Column 3] )

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

Anonymous
Not applicable

@Mariusz

This one doesn't quite work. It calculates based on the non-aggregated before they are summed into TaktDiff. 

 

Meauretry.png

Hi @Anonymous 

 

Try with group by

Measure = 
SUMX( 
    GROUPBY( 
        'Table', 
        'Table'[Serial], 
        'Table'[Tier2], 
        "@Column 3", SUMX( CURRENTGROUP(), 'Table'[Column 3] ) ),
    [TaktDiff] - [@Column 3] 
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Anonymous
Not applicable

Measure = 
SUMX( 
    GROUPBY( 
        'Table', 
        'Table'[Serial], 
        'Table'[Tier2], 
        "@Column 3", SUMX( CURRENTGROUP(), 'Table'[Column 3] ) ),
    [TaktDiff] - [@Column 3] 
)

 

This seems to have the same issues as the previous SUMX function. Although, I am not sure why. The issue seems to be from previously calculating the SUM of TakDiff based on Serial.

@Anonymous you have to be specific which solution you tried and not worked, you have few awesome people replied to your post, be more specific. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Sorry, I tried to tag the solutions as I was trying them. 

 

Looks like your solution 

 

Diff = [Your Measure] - SUM ( Table[Column3] )

 

works if you swap the SUM out with MIN. Using the sum function seems to give me the same issue as using the SUMX function in Mariusz's solution. I am not 100% sure why though.

 

Either way, thanks for the help.

@Anonymous since you already know that issue is that you cannot subtract column from a measure means you need to convert your column to a measure and in this case, you can use aggregation methods like MIN or MAX or SUM, try this. I would use a SUM function

 

 

Diff = [Your Measure] - SUM ( Table[Column3] )

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

amitchandak
Super User
Super User

Not sure I got it, Try like

sumx(summarize(Table,Table[Serial], Table[Tier], "_1",sum(Table[TaktDiff]), "_2",sum(Table[Column3])),[_1] -[_2])

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

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors