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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
David1780
Frequent Visitor

Display previous profit value from non-concurrent dates across multiple categories

Hello Team,

 

I am looking for a DAX formula that looks up the most recent previous profit figure of a project. The dates are not sequentual. This has been covered in a previous post linked below but my data set includes profit from multiple projects. I am looking to see the previous profit from the same project. Data looks like this:

 

ProjectDateProfit
22222215/09/2022 $          1,500.00
22222215/10/2022 $          1,500.00
1112221/11/2022 $             100.00
878787814/11/2022 $               50.00
11122215/11/2022 $             100.00
22222215/11/2022 $          1,500.00
878787824/11/2022 $             100.00
878787811/12/2022 $             110.00
22222215/12/2022 $             500.00
11122221/12/2022 $             120.00
878787823/12/2022 $             190.00
22222215/01/2023 $             500.00
878787815/01/2023 $             555.00
1112221/03/2023 $             120.00

 

I have manually generated the expected results in the following table:

 

ProjectDateProfitPrevious
22222215/09/2022 $ 1,500.00 
22222215/10/2022 $ 1,500.001500
1112221/11/2022 $    100.00 
878787814/11/2022 $      50.00 
11122215/11/2022 $    100.00100
22222215/11/2022 $ 1,500.001500
878787824/11/2022 $    100.0050
878787811/12/2022 $    110.00100
22222215/12/2022 $    500.001500
11122221/12/2022 $    120.00100
878787823/12/2022 $    190.00110
22222215/01/2023 $    500.00500
878787815/01/2023 $    555.00190
1112221/03/2023 $    120.00120

 

Here is a link to a similar question:

https://community.powerbi.com/t5/Desktop/Previous-Value-Using-DAX/m-p/933746

 

Thanks in advance.

 

1 ACCEPTED SOLUTION

Slight adjustment to the last part of the formula.

 

Column = 
VAR _last=maxx(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[Date]<EARLIER('Table'[Date])),'Table'[Date])
return if(ISBLANK(_last),blank(),maxx(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[Date]=_last),'Table'[Profit]))

View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@David1780 

you can try this

Column = 
VAR _last=maxx(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[Date]<EARLIER('Table'[Date])),'Table'[Date])
return if(ISBLANK(_last),blank(),maxx(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[Date]=_last),'Table'[ Profit ]))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Slight adjustment to the last part of the formula.

 

Column = 
VAR _last=maxx(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[Date]<EARLIER('Table'[Date])),'Table'[Date])
return if(ISBLANK(_last),blank(),maxx(FILTER('Table','Table'[Project]=EARLIER('Table'[Project])&&'Table'[Date]=_last),'Table'[Profit]))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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