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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
NickzNickz
Helper IV
Helper IV

How to get the latest amount filter by year and month

Hi...

 

I have created the table below for our scenario purposes.

NickzNickz_0-1687760090860.png

and below is the measure I currently have to get the output but only get the latest last record ...
Filter by Year and Month

 

Latest Value Migration = 
VAR _Year = MAX(test_scenario_2[Year])
VAR _Month = MAX(test_scenario_2[Month])
VAR _Maxdate = MAXX(FILTER(test_scenario_2, test_scenario_2[Year] = _Year), test_scenario_2[Month] = _Month)
VAR _Result = MAXX(FILTER(test_scenario_2, test_scenario_2[Year] = _Year && test_scenario_2[Month] = _Month) , test_scenario_2[Migration])
Return
IF(ISBLANK(_Result),"0.00",_Result)

 

Anyone can help me to get the below result :

1)  Migration total sum for the latest year and month. The result should get = 1950

2) Please advise me if the measure can be a more simplified version or the table need an additional column...

 

 

Regards,

NickzNickz

 

2 ACCEPTED SOLUTIONS

@NickzNickz,

 

A date table would certainly be a good idea 🙂 Once created, you could simply sum the migration column, filtered on MAX( dateTable[Date] ).

View solution in original post

@NickzNickz,

 

More like this one:

 

Mesure = 
    CALCULATE(
        SUM( 'Table'[Migration] ),
        'Table'[Date] = MAX( 'Table'[Date] )
    )

 

Alf94_0-1687769749633.png

 

Best,

 

View solution in original post

5 REPLIES 5
Alf94
Solution Supplier
Solution Supplier

Hi @NickzNickz ,

 

Can you try the following?

 

Latest value migration =
VAR _year = MAX(test_scenario_2[Year])
VAR _month = MAX(test_scenario_2[Month])
RETURN
    SUMX(
        FILTER(
            test_scenario_2,
            test_scenario_2[Year] = _year && test_scenario_2[Month] = _month
        ),
        test_scenario_2[Migration]
    )

 

If I answered your question, please mark my post as a solution.

 

Best,

Hi @Alf94 ,

 

I have tested ... 

Scenario 1 - ok .. 
Scenario 2  - I add year 2023 and month 3 , result is empty as below ...

NickzNickz_0-1687765267716.png

Should I create date table and filter max from there ? ...

 

NickzNickz

 

@NickzNickz,

 

A date table would certainly be a good idea 🙂 Once created, you could simply sum the migration column, filtered on MAX( dateTable[Date] ).

@Alf94 ,

 

I have created date table as per your recommendation and below is the result.

NickzNickz_0-1687766855487.png

 

 

Latest Value Migration 3 = 
    SUMX(
        FILTER(
            test_scenario_2,test_scenario_2[Date] 
            = MAX(test_scenario_2[Date])
        ),
        test_scenario_2[Migration])

 


If I want to get only the last value, what should I change in the measure ? ...

 

NickzNickz

@NickzNickz,

 

More like this one:

 

Mesure = 
    CALCULATE(
        SUM( 'Table'[Migration] ),
        'Table'[Date] = MAX( 'Table'[Date] )
    )

 

Alf94_0-1687769749633.png

 

Best,

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.