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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Measure to find last Purchased date each month based on Customer

Hi Experts

 

How would you do a summarised table and or a measure and or calculated column to give you the last purchased date each month based on the customer in first column

CustomerDate
abc01/01/2022
abc27/01/2022
abc02/03/2022
abc22/03/2022
abc03/06/2022
abc22/06/2022
ddd01/01/2022
ddd27/01/2022
ddd02/03/2022
ddd22/03/2022
ddd03/06/2022
ddd22/06/2022
1 ACCEPTED SOLUTION

@Anonymous Please create a column with below code:-

Column =
VAR _mon =
    MONTH ( [Date] )
VAR _year =
    YEAR ( [Date] )
RETURN
    CALCULATE (
        MAX ( [Date] ),
        FILTER (
            ALL ( 'Table (7)' ),
            MONTH ( [Date] ) = MONTH ( EARLIER ( 'Table (7)'[Date] ) )
                && YEAR ( [Date] ) = YEAR ( EARLIER ( 'Table (7)'[Date] ) )
                && 'Table (7)'[Customer] = EARLIER ( 'Table (7)'[Customer] )
        )
    )

Now use this column on your visual

Samarth_18_0-1645716945541.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

7 REPLIES 7
Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

You can create a measure like below:-

_measure =
CALCULATE (
    MAX ( 'Table (7)'[Date] ),
    FILTER (
        ALL ( 'Table (7)'[Date] ),
        MONTH ( 'Table (7)'[Date] ) = MONTH ( SELECTEDVALUE ( 'Table (7)'[Date] ) )
            && YEAR ( 'Table (7)'[Date] ) = YEAR ( SELECTEDVALUE ( 'Table (7)'[Date] ) )
    )
)

 

Output:-

image.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Hi Samarth - I just want to show the max date for each month - Not all the data.... please..

Anonymous
Not applicable

end result

CustomerDate
abc27/01/2022
abc22/03/2022
abc22/06/2022
ddd27/01/2022
ddd22/03/2022
ddd22/06/2022

@Anonymous Please create a column with below code:-

Column =
VAR _mon =
    MONTH ( [Date] )
VAR _year =
    YEAR ( [Date] )
RETURN
    CALCULATE (
        MAX ( [Date] ),
        FILTER (
            ALL ( 'Table (7)' ),
            MONTH ( [Date] ) = MONTH ( EARLIER ( 'Table (7)'[Date] ) )
                && YEAR ( [Date] ) = YEAR ( EARLIER ( 'Table (7)'[Date] ) )
                && 'Table (7)'[Customer] = EARLIER ( 'Table (7)'[Customer] )
        )
    )

Now use this column on your visual

Samarth_18_0-1645716945541.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi @Anonymous It would be very helpful if you could share the snapshot of expected output?

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

TheoC
Super User
Super User

Hi @Anonymous 

 

Can you try the following as a new table. Apologies, am on phone so can't test syntax. 

 

Table =
SUMMARIZE ( 'Table', 'Table'[Customer], "MaxDate", MAX ( 'Table'[Date] ) )

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

@Anonymous did you try my solution?

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.