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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Calculated Column from another column - change all but the latest date.

i have three columns - status, user and month.   the status is the same for every month for each user but it is only correct for the last month, all earlier entries should be "Active".

 

I had a solution in power query using a function that works on my home latest release power BI version, howerver my work power BI desktop is an older version due to IT policy and i get a function error.   

 

is there a way in DAX to produce the column i need?

 

how it is:

StatusUserMonth
CompleteUser11/01/2021
CompleteUser11/02/2021
CompleteUser11/03/2021
WithdrawnUser21/01/2021
WithdrawnUser21/02/2021
WithdrawnUser21/03/2021
ActiveUser31/01/2021
ActiveUser31/02/2021
ActiveUser31/03/2021

 

how it should be:

StatusUserMonth
Activeuser11/01/2021
ActiveUser11/02/2021
Completeuser11/03/2021
ActiveUser21/01/2021
ActiveUser21/02/2021
WithdrawnUser21/03/2021
ActiveUser31/01/2021
ActiveUser31/02/2021
ActiveUser31/03/2021
1 ACCEPTED SOLUTION
ERD
Community Champion
Community Champion

@Anonymous ,

You can try this measure:

Measure = 
VAR currentUser = MAX ( T[User] )
VAR latestDate = MAXX ( FILTER ( ALL ( T ), T[User] = currentUser ), T[Month] )
VAR latestStatus =
    CALCULATE (
        MAX ( T[Status] ),
        T[User] = currentUser,
        T[Month] = latestDate
    )
RETURN
    IF ( MAX ( T[Month] ) = latestDate, latestStatus, "Active" )

ERD_0-1626241569154.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

8 REPLIES 8
SanketBhagwat
Solution Sage
Solution Sage

Can you please share the sample data file?

The data you provided seems to be incomplete as User2 has different status for same day.

 

Regards,

Sanket Bhagwat

Anonymous
Not applicable

appoligies - i have changed the data in the post.  should have been 3 users. 

ERD
Community Champion
Community Champion

@Anonymous ,

you have 2 different values for the last month for User 2..

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

i've updated the post - it hsould have been 3 users. 

ERD
Community Champion
Community Champion

@Anonymous ,

You can try this measure:

Measure = 
VAR currentUser = MAX ( T[User] )
VAR latestDate = MAXX ( FILTER ( ALL ( T ), T[User] = currentUser ), T[Month] )
VAR latestStatus =
    CALCULATE (
        MAX ( T[Status] ),
        T[User] = currentUser,
        T[Month] = latestDate
    )
RETURN
    IF ( MAX ( T[Month] ) = latestDate, latestStatus, "Active" )

ERD_0-1626241569154.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

Hi ERD,  thanks for the reply - i'm not sure if i am doing something wrong but when i'm doing it i get "Active" for all results

thisguy_0-1626391307967.png

 

  

ERD
Community Champion
Community Champion

@Anonymous , the code is for the measure, your image shows a calculated column. You need a calculated column ? If so, here the code:

New status = 
VAR currentUser = T[User]
VAR latestDate = 
    MAXX ( FILTER ( ALL ( T[User], T[Month] ), T[User] = currentUser ), T[Month] )
VAR latestStatus =
    CALCULATE (
        MAX ( T[Status] ),
        T[User] = currentUser,
        T[Month] = latestDate
    )
RETURN 
    IF ( T[Month] = latestDate, latestStatus, "Active" )

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

ERD thankyou for this - i was also able to get the first response to work once i corrected my mistake so i'll accept that as the solution as it answers the original question.   

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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