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
andra2
Helper I
Helper I

Direct Query question - latest date

Hello, 

 

I am using direct query for a table having let's say these values:

Team  Strategy  Stock   Section   Created On

X1C11/27/2022 1:14
X1C21/27/2022 1:15
X1C31/27/2022 1:16
X1C41/27/2022 1:17
X2C11/26/2022 1:18
X2C21/26/2022 1:13
X2C31/26/2022 1:12
X2C41/26/2022 1:14

 

I am trying to display in a matrix table only the latest values for same team + strategy + stock combination, no matter the section ID.  In the above case I should have displayed in the matrix table just these 2 rows:

 

Team    Strategy   Stock   Section    Created On

X1C41/27/2022 1:17
X2C11/26/2022 1:18

 

Can you, please, let me know how can I showcase this within a measure?

Thank you!

1 ACCEPTED SOLUTION

Hi @andra2 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below to judge if it is the latest created on date group by  team, strategy and stock

Flag = 
VAR _latestdate =
    CALCULATE (
        MAX ( 'Table'[Created On] ),
        ALLEXCEPT ( 'Table', 'Table'[Team], 'Table'[Strategy], 'Table'[Stock] )
    )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Created On] ) = _latestdate, 1, 0 )

2. Apply a visual-level filter with condition "Flag is 1" to the table/matrix visual

yingyinr_0-1643778152590.png

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
Anonymous
Not applicable

if you have a date table you can use today funtion or you can use max function 

and how today or max function will help? can you, please, write the measure I should be using?

Hi @andra2 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below to judge if it is the latest created on date group by  team, strategy and stock

Flag = 
VAR _latestdate =
    CALCULATE (
        MAX ( 'Table'[Created On] ),
        ALLEXCEPT ( 'Table', 'Table'[Team], 'Table'[Strategy], 'Table'[Stock] )
    )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Created On] ) = _latestdate, 1, 0 )

2. Apply a visual-level filter with condition "Flag is 1" to the table/matrix visual

yingyinr_0-1643778152590.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.