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
Afjal0611
New Member

Find compare Current QTD with Previous QTD based on today's date. ?

Find compare Current QTD with Previous QTD based on today's date. ?

When we are trying create a measure in power bi desktop the requirement is compare Current QTD with Previous QTD based on today's date .

 

If today is June 23,2023 , then QTD should be Sales for Year 2023 , 2nd Quarter ,

QTD date range is Apr 1,2023---June 22,2023

QTD Priori should be Jan 1,2023—March 22,2023 ( but the value seems like Jan 1,2023—March 31,2023) , TD – to date , not should be full Quarter

QTD prior year should be Apr 1,2022- June 22,2022 ( but the value seems like Apr 1,2023—June 30,2023), TD – to date , not should be full Quarter

 

1. QTD Prior = calculate([Measures],DATEADD(filter(DATESQTD('Dim Date'[Date]),'Dim Date'[Date]<TODAY()),-1,QUARTER))

2. QTD Prior year = calculate([Measures],DATEADD(filter(DATESQTD('Dim Date'[Date]),'Dim Date'[Date]<TODAY()),-1,YEAR))

The above query i am using but it is not working as per the requirement.

Power BI @Experteam 

1 REPLY 1
Ahmedx
Super User
Super User

pls try this

 

QTD Prior =  // this sum of previous QUARTER
VAR _ToDay = TODAY()-1
VAR _DateTable1= CALCULATETABLE(DATEADD('Calendar'[Date],-1,QUARTER),'Calendar'[Date]=_ToDay)
VAR _StartQuarter = STARTOFQUARTER(_DateTable1)
VAR _DateTable2 = DATESBETWEEN('Calendar'[Date],_StartQuarter,_DateTable1)
RETURN
 CALCULATE([Sales],_DateTable2) 
--------
QTD Prior year  = // this sum of previous year
VAR _ToDay = TODAY()-1
VAR _DateTable1= CALCULATETABLE(DATEADD('Calendar'[Date],-1,YEAR),'Calendar'[Date]=_ToDay)
VAR _StartQuarter = STARTOFQUARTER(_DateTable1)
VAR _DateTable2 = DATESBETWEEN('Calendar'[Date],_StartQuarter,_DateTable1)
RETURN
 CALCULATE([Sales],_DateTable2) 

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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