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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.