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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

use if to find difference between columns from specific date

Hello, i want to find varriance = sum( tableA[cost]) - sum(tableB[cost]) .

i have data from before 2022, i want to use the varriance to calculate from 2022-01-28 until now while anything before just give me a 0 . so im assuming i use the if synatx?

any help?

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

Do both table A and table B have a date column? If so, please have a try.

Create a measure.

measure=var _a=calculate(sum(tableA[cost]),filter(all(tableA),tableA[date]>=date(2022,1,28))
var _b=calculate(sum(tableB[cost]),filter(all(tableB),tableB[date]>=date(2022,1,28))
return
_a-_b

If I have misunderstood your meaning, pelase provide more details with your desired output and sample data without privacy information.

 

Best Regards

Community Support Team _ Polly

 

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

Nathaniel_C
Community Champion
Community Champion

Hi @Anonymous ,

Try this 

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 

 

Variance =
var _date = tableA [date]
var _TAsum = MAX( tableA[cost]) 
var _TBsum = MAX(tableB[cost])

Return If( _date > 1/27/2022,_TAsum-_TBsum, 0)

//assumes dates match between TableA and TableB drop this on your table visual, calcs row by row

 

 





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

Proud to be a Super User!




Anonymous
Not applicable

it didnt work for me 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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