cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PedroReis Regular Visitor
Regular Visitor

DAX Problem: Previous Year, no Date Table for time intelligence

I want to do a calculated measure which shows me the total sales for December of the previous year.

I do not have a date recognized table to use, so i want to use a numeric calculation for the year. (because of index optimization reasons)

 

Can someone help me with the DAX for this measure?

 

Total Sales DEC LY = 
CALCULATE([Total Sales],
DIM_YEAR[Year]= .......
DIM_MONTH[Month]=12
)
 

 

problem.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 
1 ACCEPTED SOLUTION

Accepted Solutions
PedroReis Regular Visitor
Regular Visitor

Re: DAX Problem: Previous Year, no Date Table for time intelligence

Just found the way of doing it; I did not know I needed to specifically use a variable

 

Total Sales DEC LY = 
VAR LY = LASTNONBLANK(DIM_YEAR[Year],1)-1
Return  
CALCULATE([Total Sales],
DIM_YEAR[Year]=LY,
DIM_MONTH[Month]=12
)

View solution in original post

3 REPLIES 3
Super User
Super User

Re: DAX Problem: Previous Year, no Date Table for time intelligence

@PedroReis not sure why you don't want date dimension in your model, anyhow try this.

 

Total Sales DEC LY = 
CALCULATE([Total Sales],
DIM_YEAR[Year]= DIM_YEAR[YEAR] - 1
DIM_MONTH[Month]=12
)





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

Proud to be a Datanaut! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





PedroReis Regular Visitor
Regular Visitor

Re: DAX Problem: Previous Year, no Date Table for time intelligence

Just found the way of doing it; I did not know I needed to specifically use a variable

 

Total Sales DEC LY = 
VAR LY = LASTNONBLANK(DIM_YEAR[Year],1)-1
Return  
CALCULATE([Total Sales],
DIM_YEAR[Year]=LY,
DIM_MONTH[Month]=12
)

View solution in original post

PedroReis Regular Visitor
Regular Visitor

Re: DAX Problem: Previous Year, no Date Table for time intelligence

Thanks for the suggestions. I had tested something like that, but the something argument for the DIM[Year] = someting cannot be a column reference, has to be a measure or a variable.

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 370 members 3,501 guests
Please welcome our newest community members: