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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Select current Quarter and Year until today

Hi there,

 

I am trying to show the following graphs:

 

  • Cumulative year to date sales vs. Cumulative sales target
  • Cumulative quarter to date sales vs. Cumulative sales target
  • Cumulative month to date sales vs. Cumulative sales target

 

For the month to date I have created the following formula to only filter out the days of the current month including today:

 

Current Month Until Today = IF(YEAR(Dates[Date]) = YEAR(TODAY()) && MONTH(Dates[Date]) = MONTH(TODAY()) && DAY(Dates[Date]) <= DAY(TODAY()) ,1,0)
 
Reason why I did this is because I only want the graph to show data until today and not for the rest of the days of the month. For month to date this works perfectly. However, for year and quarter to date this does not work well. For quarter to date I have the following formula: 
 
Current Quarter Until Today = IF(YEAR(Dates[Date]) = YEAR(TODAY()) && QUARTER(Dates[Date]) = QUARTER(TODAY()) && DAY(Dates[Date]) <= DAY(TODAY()) ,1,0)
 
This formula looks like it would work but it selects the dates in the current month until today, then skips the rest of the current month and selects all days of the rest of the quarter. 
 
Can someone please help me fix the formula for Current Quarter Until Today and Current Year Until Today?
 
Thank you in advance!
 
Best,
 
David
1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , You can use time intelligence for this , create a date table and join date from both tables to that

 

example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))

 

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"))

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Power BI — Qtr on Qtr with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
https://www.youtube.com/watch?v=8-TlVx7P0A0
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

 

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors