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

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
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.