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

HELP!!!!! Return the most recent text value per group based on date

Hi,

I'd like to get some help on an efficient DAX solution for calculating the most recent value (text) per group.

As the below picture shows, I have the customers' visiting history by date by location. I am looking for a solution to show the most recent visited store's information per customer.

Since the store column is a text datatype, I am not able to utilize the MIN/ MAX function so well around that.

 

explain.PNG

 

Looking forward to any creative comments! Thank you in advance!!

2 ACCEPTED SOLUTIONS
Icey
Community Support
Community Support

Hi @jts_ ,

 

Try to create a measure like so:

Latest Store =
MAXX (
    TOPN (
        1,
        ALLEXCEPT ( 'Table', 'Table'[Customer] ),
        CALCULATE ( MAX ( 'Table'[Date] ) ), DESC
    ),
    [Store]
)

Icey_0-1655776667976.png

 

Best Regards,

Icey

 

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

Hi,

You may refer to my solution in this file.

Hope this helps.

Untitled.png


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

View solution in original post

4 REPLIES 4
VahidDM
Super User
Super User

Hi @jts_ 

 

Can you share the sample of your data in a text format here to be able to copy and paste that?

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

Hi @VahidDM ,

 

Thanks for your response. Sure thing- Please see below for the text version of the data. Text in red are the result that I wanted to get. Thank you!

 

Date       Customer   Store

1/1/2022   Amy         A

3/1/2022   Amy         A

5/1/2022   Amy         C

-------------------------------------

2/1/2022   Brenda     D

3/1/2022   Brenda     A

-------------------------------------

4/1/2022   Carmela   B

5/1/2022   Carmela   A

6/1/2022   Carmela   B

 

Hi,

You may refer to my solution in this file.

Hope this helps.

Untitled.png


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

Hi @jts_ ,

 

Try to create a measure like so:

Latest Store =
MAXX (
    TOPN (
        1,
        ALLEXCEPT ( 'Table', 'Table'[Customer] ),
        CALCULATE ( MAX ( 'Table'[Date] ) ), DESC
    ),
    [Store]
)

Icey_0-1655776667976.png

 

Best Regards,

Icey

 

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.