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
Anonymous
Not applicable

calculating a collumn per row level

Hi everyone,

i have the following data set

Postigo_0-1603149738303.png

With each row represents the moviment in a account,i tried to create a Measure where i have to do  Credit - Debit while i filter everything that if before my "DateTime" collumn, but it doesnt work the way i imagined, i did a model of what i expect in excel

 
 
 
 
 
 

Screenshot 2020-10-19 203329.png

 

Basically i need to use my Measure Column deduct my values per row level,  (5555-2246 = 3309) ,(3309-4465 = -6711)and goes on to give the results of my  "Expected Value"



Thanks everyone


1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Would you please try to use the following measure:

 

final balance = CALCULATE(SUM('Table'[Credit])-SUM('Table'[Debit]),FILTER(ALLSELECTED('Table'),'Table'[DateTime]<= MAX('Table'[DateTime])))

 

 

Capture4.PNG

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

How did you arrive at the number -6.711?  A mystery indeed.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

My mistake, the excel formula was wrong when i created that example, this one is the new and right number

Postigo_0-1603152810247.png

 

Hi,

This approach will work:

  1. Remove time stamp from the DateTime column
  2. Create a Calendar Table
  3. Build a relationship from the Date column (from which you seperated the time stamp) to the Date column of your Calendar Table
  4. To your visual, drag the Date from the Calendar Table
  5. Write these measures

Total debit = SUM(Data[Debit])

Total credit = SUM(Data[Credit])

Net = [Total credit]-[Total debit]

Running net = calculate([net],datesytd(calendar[date],"31/12"))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Please try this expression, replacing Table1 with your actual table name.

 

Total =
VAR thisdate =
    MIN ( Table1[Date] )
RETURN
    CALCULATE (
        SUMX (
            Table1,
            Table1[Credit] - Table1[Debit]
        ),
        ALL ( Table1 ),
        Table1[Date] <= thisdate
    )

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thats it!! this is worked in my sample, but when i tried in my original file (with a slicer) the measure table started to loading and dont display the measure @mahoneypat 

Postigo_0-1603160055632.png

(My original file, if you can see the loading icon on my table top, i just used the filter os the same table)

Postigo_1-1603160122696.png

 

Here i used a filter too, but the measure worked perfectly


Hi @Anonymous ,

 

Would you please try to use the following measure:

 

final balance = CALCULATE(SUM('Table'[Credit])-SUM('Table'[Debit]),FILTER(ALLSELECTED('Table'),'Table'[DateTime]<= MAX('Table'[DateTime])))

 

 

Capture4.PNG

 

 

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

 

Best Regards,

Dedmon Dai

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.