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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NimaiAhluwalia
Continued Contributor
Continued Contributor

DAX Logical Issue

Hello I have a usecase which i am not sure how to create a DAX for, need a hand!!

 

NimaiAhluwalia_0-1700052747845.png

 

If the above is my table and i want to build a calculated column as previous, which takes the priormonth value of the project (the value is status column here for me) and displays the result in the previous column as shown above!!

 

Problem - I can use Time intelligence function previousmonth but how it will filter the exact row for me, example, for the Project 1 - Nov, if i use Prreviousmont it will caputure  Project 1 - oct and  Project 2 - Oct (as they will be displayed due to having a date value of Oct), But i only want to get the data for  Project 1 - Oct for  Project 1 - Nov.

 

Please let me know if you want some more clarificaition or please suggest if we can do it by measure as well, i am open to all suggestions thanks

 

@amitchandak 

@Greg_Deckler 

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @NimaiAhluwalia 

 

You can try the following methods.

Column = 
Var _Previous=MAXX(FILTER('Table',[Project ID]=EARLIER('Table'[Project ID])&&[Date]<EARLIER('Table'[Date])),[Date])
Return
CALCULATE(MAX('Table'[Status]),FILTER('Table',[Project ID]=EARLIER('Table'[Project ID])&&[Date]=_Previous))

vzhangti_0-1700189544921.png

Measure = 
Var _Previous=MAXX(FILTER(ALL('Table'),[Project ID]=SELECTEDVALUE('Table'[Project ID])&&[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Return
CALCULATE(MAX('Table'[Status]),FILTER(ALL('Table'),[Project ID]=SELECTEDVALUE('Table'[Project ID])&&[Date]=_Previous))

vzhangti_1-1700189681723.png

Is this the result you expect? Please see the attached document.

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @NimaiAhluwalia 

 

You can try the following methods.

Column = 
Var _Previous=MAXX(FILTER('Table',[Project ID]=EARLIER('Table'[Project ID])&&[Date]<EARLIER('Table'[Date])),[Date])
Return
CALCULATE(MAX('Table'[Status]),FILTER('Table',[Project ID]=EARLIER('Table'[Project ID])&&[Date]=_Previous))

vzhangti_0-1700189544921.png

Measure = 
Var _Previous=MAXX(FILTER(ALL('Table'),[Project ID]=SELECTEDVALUE('Table'[Project ID])&&[Date]<SELECTEDVALUE('Table'[Date])),[Date])
Return
CALCULATE(MAX('Table'[Status]),FILTER(ALL('Table'),[Project ID]=SELECTEDVALUE('Table'[Project ID])&&[Date]=_Previous))

vzhangti_1-1700189681723.png

Is this the result you expect? Please see the attached document.

 

Best Regards,

Community Support Team _Charlotte

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

Anonymous
Not applicable

Try the following:

CALCULATE(SELECTEDVALUE('YourTable'[Status]), FILTER(ALL('YourTable'),

                                                    'YourTable'[Project ID] = SELECTEDVALUE('YourTable'[Project ID])

                                                    && MONTH(SELECTEDVALUE('YourTable'[Date])) = MONTH('YourTable'[Date]) - 1

                                                    && YEAR(SELECTEDVALUE('YourTable'[Date])) = YEAR('YourTable[Date]))

)

 

This should effectively remove all of the row level filter context, then reapply it but setting the previous month as the value to find the status for. Hope this helps, let me know if you have any issues or questions.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors