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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Milan14
Frequent Visitor

Calculate user balance for a specific date

Hi everyone,

 

I would like to calculate the user balance for a specific month. 

 

Sample data:

Milan14_1-1675938336344.png

 

When I applied filter [Year] = 2022 and [Month] = December, it should take the balance with GREEN highlight.

Milan14_2-1675938382402.png

 

Expected outcome:

Milan14_3-1675938725540.png

 

Does anyone have any ideas what kind of formula I should apply?

 

Any help would be much appreciated.

 

Thanks in advance!

 

Kindly Regards,

Milan

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Milan14 
Please refer to attaches sample file with the solution

2.png

1.png

Balance Measure = 
VAR SelectedDate = MAX ( 'Date'[Date] )
VAR Result =
    SUMX ( 
        VALUES ( 'Table'[UserID] ),
        VAR CurrentIDTable = CALCULATETABLE ( 'Table' )
        VAR MaxDateRecord = TOPN ( 1, FILTER ( CurrentIDTable, 'Table'[Date] <= SelectedDate ), 'Table'[Date] )
        RETURN
            MAXX ( MaxDateRecord, 'Table'[Balance] )
    )
RETURN
    Result

View solution in original post

2 REPLIES 2
Milan14
Frequent Visitor

Hi @tamerj1,

 

Sorry for the let reply..

Thanks for your help. It's exactly what I need !   

 

Milan

tamerj1
Super User
Super User

Hi @Milan14 
Please refer to attaches sample file with the solution

2.png

1.png

Balance Measure = 
VAR SelectedDate = MAX ( 'Date'[Date] )
VAR Result =
    SUMX ( 
        VALUES ( 'Table'[UserID] ),
        VAR CurrentIDTable = CALCULATETABLE ( 'Table' )
        VAR MaxDateRecord = TOPN ( 1, FILTER ( CurrentIDTable, 'Table'[Date] <= SelectedDate ), 'Table'[Date] )
        RETURN
            MAXX ( MaxDateRecord, 'Table'[Balance] )
    )
RETURN
    Result

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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