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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
djb_bc
New Member

[Cash Closing Balance] respective to date context

Hi.
I have a DAX calc that needs solving, hopefully someone has more brain-power than me to solve it as I'm at a loss.

 

Essentially I want to get the latest non empty Ledger[CashClosingBalance] within the context of whatever date I'm pivotting on, usually by month.

The Ledger table is such that it has [PlayerId], [ActivityDate] and [CashClosingBalance].

The slight complexity is that not every player has a record for every month. So if I want to look at balances as at the end of April, a player's last entry in the table may be as far back as Feb, but I still want to include this as their balance hasn't changed and needs to be brought-forward. A simplistic view is seen here.


ClosingBalance.jpg
 Can anybody help with the solution please.

Cheers.

1 REPLY 1
v-xinruzhu-msft
Community Support
Community Support

Hi @djb_bc 

You can create a column in the table

Column =
VAR a =
    MAXX (
        FILTER ( Ledger, [PlayerId] < EARLIER ( Ledger[PlayerId] ) ),
        [PlayerId]
    )
VAR b =
    FILTER ( Ledger, [PlayerId] = a )
RETURN
    IF (
        EOMONTH ( [Activity Date], 0 ) <> EOMONTH ( MAXX ( b, [Activity Date] ), 0 ),
        MAXX (
            FILTER ( b, [Activity Date] = MAXX ( b, [Activity Date] ) ),
            [CashClosingBalance]
        )
    )

Then create a measure in the table

Measure=SUM(Ledger[CashClosingBalance])+CALCULATE(SUM([Column]),ALLSELECTED(Ledger),Ledger[Activity Date]<=SELECTEDVALUE(Ledger[Activity Date]))

Output

vxinruzhumsft_0-1682908998733.png

 

Best Regards!

Yolo Zhu

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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