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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
RafaelAri
Helper III
Helper III

Get latest date values

Hello,

I have a table of items, with a "Status" and "Status Date" columns, of different statuses, for the same item.

It is required to build a measure that will summarize the "Qty" field, In case a status ends with "\1" and the date for that status is the most recent, for that item.

See an example for 1 specific item in the picture:

RafaelAri_0-1730780712830.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @RafaelAri ,

Thanks for all the replies!
And @RafaelAri , I think rajendraongole1's reply is close, so I modified his response a bit:
Here is my sample data:

vjunyantmsft_0-1730858798205.png


I changed his DAX into this:

Latest_Qty_With_Status_1 = 
VAR _RecentDate = 
CALCULATE(
    MAX('Table'[Status Date]),
    FILTER(
        ALL('Table'),
        RIGHT('Table'[Status], 2) = "\1" && 'Table'[Item] = MAX('Table'[Item])
    )
)
RETURN
CALCULATE(
    SUM('Table'[Qty.]),
    ALL('Table'),
    RIGHT('Table'[Status], 2) = "\1" && 'Table'[Item] = MAX('Table'[Item]) && 'Table'[Status Date] = _RecentDate
)

And the final output is as below:

vjunyantmsft_1-1730858853817.png


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

View solution in original post

11 REPLIES 11
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.  For that dataset, show the expected result very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

OK, I will do so next time

Anonymous
Not applicable

Hi @RafaelAri ,

Thanks for all the replies!
And @RafaelAri , I think rajendraongole1's reply is close, so I modified his response a bit:
Here is my sample data:

vjunyantmsft_0-1730858798205.png


I changed his DAX into this:

Latest_Qty_With_Status_1 = 
VAR _RecentDate = 
CALCULATE(
    MAX('Table'[Status Date]),
    FILTER(
        ALL('Table'),
        RIGHT('Table'[Status], 2) = "\1" && 'Table'[Item] = MAX('Table'[Item])
    )
)
RETURN
CALCULATE(
    SUM('Table'[Qty.]),
    ALL('Table'),
    RIGHT('Table'[Status], 2) = "\1" && 'Table'[Item] = MAX('Table'[Item]) && 'Table'[Status Date] = _RecentDate
)

And the final output is as below:

vjunyantmsft_1-1730858853817.png


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

ryan_mayu
Super User
Super User

you can create a column to mark if need to filter

 

Column = IF(RIGHT('Table'[Status],2)="\1"&&'Table'[Status Date]<>CALCULATE(max('Table'[Status Date]),ALLEXCEPT('Table','Table'[Item])),"N","Y")
 
11.PNG
 
then you can only sum those data that column ="Y"




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Rupak_bi
Super User
Super User

Hi @RafaelAri ,

 

Try below dax. 

 

result= 

var max_date = calculate(max(table,status date),allexcept(table, item))
return
calculate(sum(table,qty),allexcept(table,item),status date = max_date, RIGHT(table,status, 2) = "\1"))

alternate dax:

result= 

var max_date = calculate(max(table,status date),allexcept(table, item))
return
sumx(filter(allexcept(table,item),status date = max_date&& right(table,status,2)="\1"),qty)

 

 

both should work





Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

Thanks, I tryed this solution, but it is not what I need

RafaelAri
Helper III
Helper III

Thanks , but I don't get the results.
I see that I get results in my visual even if the Status with "\1" is not the latest.

It looks like the MAX with the FILTER are not correct 

danextian
Super User
Super User

Hi @RafaelAri 

Assuming the status is to be calculted by Status and Item columns, try this measure:

MyMeasure =

VAR __LATEST_STATUS_DATE =
    CALCULATE (
        MAX ( 'table'[Status Date] ),
        ALLEXCEPT ( 'table', 'table'[Status], 'table'[Item] )
    )
RETURN
    CALCULATE (
        SUM ( 'table'[Qty.] ),
        KEEPFILTERS ( 'table'[Status Date] = __LATEST_STATUS_DATE )
    )

 

If you want a calculated column to be used in a slicer/as a filter:

Is Latest=
VAR __LATEST_STATUS_DATE =
    CALCULATE (
        MAX ( 'table'[Status Date] ),
        ALLEXCEPT ( 'table', 'table'[Status], 'table'[Item] )
    )
RETURN
    table'[Status Date] = __LATEST_STATUS_DATE  --will return TRUE/FALSE

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks, I tried but didn't get the results I expected.

rajendraongole1
Super User
Super User

Hi @RafaelAri - you can create a measure that identifies the latest entry for each item with a status ending in "\1" and then sums the quantity for those entries. 

write dax logic as below:

Latest_Qty_With_Status_1 =
VAR LatestDatePerItem =
CALCULATE(
MAX('Table'[Status Date]),
FILTER(
'Table',
RIGHT('Table'[Status], 2) = "\1"
)
)
RETURN
SUMX(
FILTER(
'Table',
RIGHT('Table'[Status], 2) = "\1" &&
'Table'[Status Date] = LatestDatePerItem
),
'Table'[Qty]
)

 

you can change 'Table' with the actual name of your table in Power BI.

 

Hope this logic helps. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks, this is helpful, I'm trying to use this solution

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors