cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rogerdea
Helper III
Helper III

Previous year measure

I've been reading up on similar ish post but not found something as basic as this.

 

I am trying to count up number of records in a table, but only for the previous year.  My DAX syntax seems correct but returns 'blank' so it's not working.  My dax is:

 

 

Request Count (prev yr) = CALCULATE(COUNT('RequestList'[Reference]),PREVIOUSYEAR('RequestList'[RequestDate]))

 

 

Is this the wrong approach?  Why wouldn't this work?

thanks 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@rogerdea , Please use date table in all such cases.

 

Refer thsese examples and blog

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

3 REPLIES 3
rogerdea
Helper III
Helper III

Thanks both, i've managed to get the monthly breakdown for last year's requests showing on a visual by doing :

Request Count (previous year) = CALCULATE(COUNT('RequestList'[Reference]),SAMEPERIODLASTYEAR('Date table'[Date]))

 

But i can't get the current year's measure working.  When i add it to the visual it's showing the total count value per month for all years.  My measure for this is:

 

Request Count (current yr) = CALCULATE(COUNT('RequestList'[Reference]),DATESYTD(ENDOFMONTH('Date table'[Date]),"12/31"))

Any idea why?

Tahreem24
Super User
Super User

@rogerdea ,

First make sure, you have propert Date Type of Date Column. If this Date column is coming from different table so check the valid relationship exist between them.

Or Try out different DAX formula to achieve the same result.


PREV YEAR COUNT= CALCULATE(COUNT('RequestList'[Reference]),DATEADD('RequestList'[RequestDate],-1,YEAR))

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, and Sales Analysis Report
amitchandak
Super User
Super User

@rogerdea , Please use date table in all such cases.

 

Refer thsese examples and blog

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.