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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
parry2k
Super User
Super User

Balance value calculation

@Phil_Seamark@Zubair_Muhammad @Anonymous @Vvelarde @MFelix

 

Hello fellow datanuts, Attached is a sheet to calculate the value of balance and explained in "value calculation formula" how the value will be calculated. Balance value column is expected to be the result for each balance column, main columns are

 

Date

Item

In

Rate 

Balance

 

Basically calculating balance value from previous incoming entries.

 

How you guys will do it? Would like to pick your brain for the solution.

 

Thanks,

P



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.

1 ACCEPTED SOLUTION

6 REPLIES 6
Zubair_Muhammad
Community Champion
Community Champion

@parry2k

 

I think this will work...But there could be an easier way

 

Column =
VAR mybalance = Table1[Balance]
VAR temp =
    FILTER (
        Table1,
        Table1[Item] = EARLIER ( Table1[Item] )
            && Table1[Date] <= EARLIER ( Table1[Date] )
            && Table1[In] <> BLANK ()
    )
VAR temp1 =
    ADDCOLUMNS ( temp, "Rank", RANKX ( temp, [Date],, DESC, DENSE ) )
VAR temp2 =
    ADDCOLUMNS (
        temp1,
        "Cumulative", SUMX ( FILTER ( temp1, [Rank] <= EARLIER ( [Rank] ) ), [In] )
    )
VAR temp3 =
    FILTER ( temp2, [Cumulative] <= EARLIER ( Table1[Balance] ) )
VAR Fullrows =
    MAXX ( temp3, [Cumulative] )
VAR temp4 =
    TOPN (
        1,
        FILTER ( temp2, [Cumulative] > EARLIER ( Table1[Balance] ) ),
        [Date], DESC
    )
RETURN
    IF ( Table1[Balance] <> BLANK (), SUMX ( temp3, [In] * [Rate] ) )
        + SUMX ( temp4, ( mybalance - Fullrows ) * [Rate] )

@parry2k

 

File attached as well.

There are few differences

 

parry2k2.png

@Zubair_MuhammadThanks will take a look and also wondering to see if anyone else reply on this and how they will solve it.



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.

@Zubair_Muhammadi would like to accept your solution but still waiting on other experts on how they will approach it? 



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.

Vvelarde
Community Champion
Community Champion

@parry2k

 

I still trying to understand the logic involved in this.

 

Don't get it yet

 

Regards

 

Victor




Lima - Peru

@Vvelardethanks for looking into it, basically it take the balance and go backward until balance quantity is zero, in other words, allocate balance quantity backward to the "in" Quantity and multiply allocated quantity with the rate.



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.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.