Forum Discussion

MarcosGabriel's avatar
MarcosGabriel
New Member
2 years ago
Solved

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. 

  • Hi MarcosGabriel 

    You can create a measure using dax :

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

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

3 Replies

  • Hi MarcosGabriel 

    You can create a measure using dax :

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

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