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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
NickzNickz
Helper IV
Helper IV

Get latest value and latest sum value based on year and month

Hi ... 

I attached herewith the sample I have used for the testing environment :

 

Scenario #1

YearMonthNewMigration
20213123123
20216234345
20219456567
202112678789
20223234321
20226345432
20229456543
202212567654

 

Scenario #2

StateYearMonthNewMigration
A20213123123
B20213234345
C20213456567
D20213678789
A20226234321
B20226345432
C20226456543
D20226567654

 

How can I achieve the below results:

 

Scenario #1:

How can I get the latest value based on year and month for New and Migration?

 

Scenario #2:

How can I get the latest value (sum) based on year and month for New and Migration?

 

 

Thank you and advance.

Regards,

NickzNickz

1 ACCEPTED SOLUTION

@devanshi ,

 

I have made some changes to the measure based on conversion with others:

Latest Group Value Migration Final = 
// Get total amount
VAR _Result =
    SUMX(
        FILTER(
            test_scenario_2,test_scenario_2[Date] 
            = MAX(test_scenario_2[Date])
        ),
        test_scenario_2[Migration]
    )
RETURN
IF(ISBLANK(_Result),"0.00",_Result)

 

 

Latest Value Migration Final = 
// Get the last amount
VAR _Result = CALCULATE(
        SUM( test_scenario_3[Migration] ),
        test_scenario_3[Date] = MAX( test_scenario_3[Date] )
    )
RETURN
IF(ISBLANK(_Result),"0.00",_Result)

 

Regards,

NickzNickz

 

 

View solution in original post

4 REPLIES 4
devanshi
Helper V
Helper V

Scenario1 :
MaxDate = MAX('Table'[Date])

LatestNewValue = CALCULATE( MAX('Table'[Value]), ALLEXCEPT('Table'[New], 'Table'[Date] = [MaxDate]) ) LatestMigrationValue = CALCULATE( MAX('Table'[Value]), ALLEXCEPT('Table'[Migration], 'Table'[Date] = [MaxDate]) )

Scenario2:

MaxDate = MAX('YourTable'[Date])

LatestNewSum = CALCULATE( SUM('Table'[Value]), ALLEXCEPT('Table'[New], 'Table'[Date] = [MaxDate]) ) LatestMigrationSum = CALCULATE( SUM('Table'[Value]), ALLEXCEPT('Table'[Migration], 'Table'[Date] = [MaxDate] ))

Hi @devanshi ,

 

I have changed the data in the table and below is the measure  :

NickzNickz_0-1687744388064.png

 

 

 

Max Date = MAX(test_scenario_2[Date])

 

 

 

Latest Value Test = CALCULATE(MAX(test_scenario_2[Migration]),ALLEXCEPT(test_scenario_2, test_scenario_2[Date] = [Max Date]))

 

 

 

 I tried to match the measure with yours but I couldn't get .... 
 
 

@devanshi ,

 

I have made some changes to the measure based on conversion with others:

Latest Group Value Migration Final = 
// Get total amount
VAR _Result =
    SUMX(
        FILTER(
            test_scenario_2,test_scenario_2[Date] 
            = MAX(test_scenario_2[Date])
        ),
        test_scenario_2[Migration]
    )
RETURN
IF(ISBLANK(_Result),"0.00",_Result)

 

 

Latest Value Migration Final = 
// Get the last amount
VAR _Result = CALCULATE(
        SUM( test_scenario_3[Migration] ),
        test_scenario_3[Date] = MAX( test_scenario_3[Date] )
    )
RETURN
IF(ISBLANK(_Result),"0.00",_Result)

 

Regards,

NickzNickz

 

 

Hi @devanshi ,

 

1)  'Table'[Value] is a table name ? ...

2) If I have only year and month column, what should I do with MAX('Table'[Date]) ?

 

Regards,

NickzNickz

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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