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
Anonymous
Not applicable

Return a filtered table values for each category as per Latest Date

Hi, I have a scenraio where in the excel table, there are records on various dates for each category. I want to retrieve only those rows having the the latest date for that category within the table. 

See below example: 

kevindmonte_1-1615902472067.png

I wish to return only these two as per the latest Date for their category. Is this possible using DAX? I need to use Entity, Customer and Project columns as they will be constant. 

I am also trying to work this out but would appreciate any advise. 
Below is the test data.

DateEntityCustomerProjectStage
14 January 2021MiningABCTest ProjectX1
19 February 2021MiningABCTest ProjectX2
04 March 2021MiningABCTest ProjectX3
23 December 2020ExcavationXYZLive ProjectK1
12 January 2021ExcavationXYZLive ProjectK2
10 March 2021ExcavationXYZLive Project

K3

 

Below is what I want to achieve.

DateEntityCustomerProjectStage
04 March 2021MiningABCTest ProjectX3
10 March 2021ExcavationXYZLive ProjectK3

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to your needs, I did the following test. The created measure is used to calculate the value corresponding to each latest date. This calculation logic is used in the virtual table created later. Then create a virtual table, get the expected result.

v-henryk-mstf_0-1616048292299.png

Result = 
SUMMARIZE (
    'Table',
    'Table'[Entity],
    'Table'[Customer],
    'Table'[Project],
    "Stage",
        CALCULATE (
            MAX ( 'Table'[Stage] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Customer] = MAX ( 'Table'[Customer] ) )
        ),
    "Date",
        CALCULATE (
            MAX ( 'Table'[Date] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Customer] = MAX ( 'Table'[Customer] ) )
        )
)
M =
CALCULATE (
    MAX ( 'Table'[Date] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Customer] = MAX ( 'Table'[Customer] ) )
)

Here is the sample .pbix file link.

Best Regards,
Henry

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

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to your needs, I did the following test. The created measure is used to calculate the value corresponding to each latest date. This calculation logic is used in the virtual table created later. Then create a virtual table, get the expected result.

v-henryk-mstf_0-1616048292299.png

Result = 
SUMMARIZE (
    'Table',
    'Table'[Entity],
    'Table'[Customer],
    'Table'[Project],
    "Stage",
        CALCULATE (
            MAX ( 'Table'[Stage] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Customer] = MAX ( 'Table'[Customer] ) )
        ),
    "Date",
        CALCULATE (
            MAX ( 'Table'[Date] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Customer] = MAX ( 'Table'[Customer] ) )
        )
)
M =
CALCULATE (
    MAX ( 'Table'[Date] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Customer] = MAX ( 'Table'[Customer] ) )
)

Here is the sample .pbix file link.

Best Regards,
Henry

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

Anonymous
Not applicable

Many thanks @v-henryk-mstf . Exactly what I was looking for but was not able to figure out the DAX. Thanks for your help.

mohammedadnant
Impactful Individual
Impactful Individual

Hi @Anonymous 

 

Good day,

 

Check this video, it is similar concept, instead of marks you can use date.

https://youtu.be/THDmCmSozt8

 

Thanks & Regards,

Mohammed Adnan

https://www.youtube.com/c/taik18

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

Thanks & Regards,
Mohammed Adnan
Learn Power BI: https://www.youtube.com/c/taik18
Anonymous
Not applicable

Thanks for quick reply @mohammedadnant I am testing this and initial results look good. ALLEXCEPT is bit difficult to comrehend. If I were to return Entity, Customer, Project and Stage for the max date, should I include these columns in the ALLEXCEPT function?

@Anonymous 

 

yes, you can add those.

 

Thanks & Regards,

Mohammed Adnan

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

Thanks & Regards,
Mohammed Adnan
Learn Power BI: https://www.youtube.com/c/taik18

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.