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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MarcosGabriel
New Member

Calculate the difference between many values from the same date based on a condition

What's up, everybody!? How are you doing? Hope you're doing very well!

 

I recently started learning Power BI to add more value to my work at the company I'm currently working in. I want to perform some calculations between values from the same date. Let me give you an example. Suppose we have the following table with the columns Date, Situation, and Value. 

 

Date              Situation    Value

01/01/2023   paid            200

01/01/2023   unpaid        500

 

Given the example below, once the calculation is finished I'd get a new table containing the following row:

 

Date              Value

01/01/2023    -300 (unpaid - paid)

 

Because I'm new to Power BI I'm struggling to find a solution. I don't want the solution itself but I'd really like to get some orientation about which materials I could dig into to learn and solve the problem. 

 

OBS: If there are any gramatical errors above, I'd like to excuse myself because English is not my mother language. It's still a work in progress. 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @MarcosGabriel 

You can create a measure using dax :

balance = CALCULATE(SUM('Table'[value]),'Table'[Situation]="paid")- CALCULATE(SUM('Table'[value]),'Table'[Situation]="unpaid")
 
Ritaf1983_0-1693424435909.png

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

View solution in original post

3 REPLIES 3
Ritaf1983
Super User
Super User

Hi @MarcosGabriel 

You can create a measure using dax :

balance = CALCULATE(SUM('Table'[value]),'Table'[Situation]="paid")- CALCULATE(SUM('Table'[value]),'Table'[Situation]="unpaid")
 
Ritaf1983_0-1693424435909.png

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

Hi, @Ritaf1983

I did what you told me, and it worked very well! Thank you for helping me with this and for your desire to help! 

Glad to help ☺️

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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