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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
rogerdea
Helper IV
Helper IV

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.

View solution in original post

4 REPLIES 4
taxidea_tasus
New Member

I had a similar issue and your examples helped me through it. Thanks!

rogerdea
Helper IV
Helper IV

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, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.