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

Max Date or last based on specific column

Hi Experts,

 

Since i am new to Power BI, need help on the subject. The scenario is i am pulling a data set and what i want to achieve is the max or last of date based on specific column.

 

i have customers and their sub category by invoice date. i want the list of customer by applying max / last of invoice date regardless of what category it was, it should show me the last row or max row. see the example below:

 

Raw Data:

CompanyCustomerCustomer CategoryCustomer Category 2Invoice Date
XYYAB-1RetailWS COMBO01-Feb-19
XYYAB-1Domestic othersWS COMBO26-Feb-19
XYYDC-2RetailKA- SUPERMARKET13-Jan-19
XYYDC-2Domestic othersKA- SUPERMARKET

31-Jan-19

 

Final result should be below:

 

CompanyCustomerCustomer CategoryCustomer Category 2Invoice Date
XYYAB-1Domestic othersWS COMBO26-Feb-19
XYYDC-2Domestic othersKA- SUPERMARKET31-Jan-19

 

So the last date of customer AB-1 and DC-2 is 26 Feb and 31 Jan respectively. They had different category regardless of that it should show the last invoice date happened on customer level not the category level.

 

kindly let me know how it can be achieved, even if it creates a new table from existing table also im fine with it.

 

Regards

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @abbas_uddin ,

 

You need to calculate the max date and compare dates with it. Then use a flag ( a measure )to filter your data.

Measure =
VAR a =
    CALCULATE (
        MAX ( 'Table'[Invoice Date] ),
        ALLEXCEPT ( 'Table', 'Table'[Customer] )
    )
RETURN
    IF ( a = SELECTEDVALUE ( 'Table'[Invoice Date] ), 1, 0 )

Now you could set the rule in the filter pane to show data whose measure is 1.

3-1.PNG

Here is my test file for your reference.

 

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

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @abbas_uddin ,

 

You need to calculate the max date and compare dates with it. Then use a flag ( a measure )to filter your data.

Measure =
VAR a =
    CALCULATE (
        MAX ( 'Table'[Invoice Date] ),
        ALLEXCEPT ( 'Table', 'Table'[Customer] )
    )
RETURN
    IF ( a = SELECTEDVALUE ( 'Table'[Invoice Date] ), 1, 0 )

Now you could set the rule in the filter pane to show data whose measure is 1.

3-1.PNG

Here is my test file for your reference.

 

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

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.