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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate year to date value based on the month selected in a slider

I have a date column CREATE_DATE and an ID column.  I would like to display in a card the count of the year-to-date of Ids based on a slider which is controlled by a column called MMM_YY.

For example if the User selects the slider to be 'January 2019" then the YTD is the number of rows in the ID column which could be 10.  However if the User selects March 2019 in the slider the values displayed in the card is 45 (say).

My dax expression does not work.  Could anybody help?  Thank you,

Count of CSR_NO_YTD_WITH_FILTER =
CALCULATE (
COUNT(WATER_QUALITY_APPREARANCE_DB[ID]),
FILTER(WATER_QUALITY_APPREARANCE_DB, WATER_QUALITY_APPREARANCE_DB[CREATE_DATE] <= MAX(WATER_QUALITY_APPREARANCE_DB[MMM_YY])
))
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

You should try using SAMEPERIODLASTYEAR

 

Total Sales YTD Last Year = CALCULATE([Total Sales YTD],SAMEPERIODLASTYEAR('date'[date]))

In your case. First, find the date and use that in the above formula

Var1 date1 =calculate (max(WATER_QUALITY_APPREARANCE_DB[created_date]),(WATER_QUALITY_APPREARANCE_DB[MMM_YY]))

 

 

Refer

https://community.powerbi.com/t5/Desktop/How-to-display-sales-YTD-and-sales-last-YTD-over-years/td-p...

https://databear.com/power-bi-tips-calculating-year-to-date-values/

 

Preferably have a date calendar and marked that to the date calendar in the Model view

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

You should try using SAMEPERIODLASTYEAR

 

Total Sales YTD Last Year = CALCULATE([Total Sales YTD],SAMEPERIODLASTYEAR('date'[date]))

In your case. First, find the date and use that in the above formula

Var1 date1 =calculate (max(WATER_QUALITY_APPREARANCE_DB[created_date]),(WATER_QUALITY_APPREARANCE_DB[MMM_YY]))

 

 

Refer

https://community.powerbi.com/t5/Desktop/How-to-display-sales-YTD-and-sales-last-YTD-over-years/td-p...

https://databear.com/power-bi-tips-calculating-year-to-date-values/

 

Preferably have a date calendar and marked that to the date calendar in the Model view

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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