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

Top Solution Authors