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
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

@parry2k

 

File attached as well.

There are few differences

 

parry2k2.png


Regards
Zubair

Please try my custom visuals

View solution in original post

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] )

Regards
Zubair

Please try my custom visuals

@parry2k

 

File attached as well.

There are few differences

 

parry2k2.png


Regards
Zubair

Please try my custom visuals

@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
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.