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
Anonymous
Not applicable

Column with previous date

Hello!

 

i am currently using this DAX as a calculated column to return the previous periods usertotal:


Prev_Date =
VAR CompanyID = table[companyId]
VAR Date1 = table[Date]
VAR Pre_Date = CALCULATE(MAX(table[Date]),FILTER(table,table[companyId]=CompanyID),FILTER(table,table[Date]<Date1))
VAR Prev_Val = CALCULATE(MAX(table[UsersTotal]),FILTER(table,table[companyId]=CompanyID),FILTER(table,table[Date]=Pre_Date))
RETURN IF(Prev_Val=BLANK(),0,Prev_Val)

 

What I would like to do is adjust this DAX to return the prevous period date rather then the user total 

 

How can I adjust this DAX to return the prevous Date?

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Why can't you just return the Pre_Date variable? It seems you've already calculated it. Just chang the last line to Pre_Date and get rid of the IF() statement.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

Why can't you just return the Pre_Date variable? It seems you've already calculated it. Just chang the last line to Pre_Date and get rid of the IF() statement.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

I literally did that and it didnt work, I just retried and it worked thank you

Excellent! Probably some comma or space messing it up the first time you tried.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.