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.
Hi,
I am trying to create a slicer that can switch between MTD, QTD and YTD for all metrics. However, I am stuck at how to get QTD for Last year. Basically i want to show (Current yr QTD-Last year QTD)/Last Yr QTD -1 as a percentage.
I have the measures for YTD and once i have QTD and MTD as well, then how do i make the selection work for all the three (MTD,YTD and QTD) as shown in the picture below.
Solved! Go to Solution.
@amitchandak : I think i found a way to calculate Fiscal Quarter. The below formula works great.
QTD
FQTD = CALCULATE (
[Sales total],
FILTER (
ALL ( 'Dates' ),
'Dates'[Fin Year] = VALUES(Dates[Fin Year])
&& 'Dates'[Quarter] = VALUES ( 'Dates'[Quarter] )
&& 'Dates'[Date] <= MAX ( 'Dates'[Date])
))
LYQTD =
CALCULATE (FQTD, sameperiodlastyear(Dates[Date])
Thanks for your help!
These are formulas you can use.
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date Filer],-1,MONTH))))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date Filer],-12,MONTH))))
MTD (Year End) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR('Date'[Date Filer])))
MTD (Last Year End) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR(dateadd('Date'[Date Filer],-12,MONTH),"8/31")))
QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date Filer])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,QUARTER)))
Next QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],1,QUARTER)))
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,Year)))
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date Filer])))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date Filer],-1,Year)))
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH))
Dynamic Selection
https://community.powerbi.com/t5/Desktop/Dynamic-Metrics-Selection/td-p/605838
https://community.powerbi.com/t5/Desktop/Dynamic-measure-values-based-on-slicer-selection/td-p/41731...
https://community.powerbi.com/t5/Desktop/How-to-display-different-measures-using-a-selector/td-p/131...
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
Hi @amitchandak : I tried the formula for last year QTD but it doesnt work. the below formula doesnt return any value.
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,Year)))
Not sure if i missed anything.
When you do not view it by time or choose a date. The default date is the end date of the calendar.
@amitchandak : oh ok. Got it. Thanks!
Now, how do i connect the slicer (MTD/QTD/YTD) to toggle according to the selection?
for starters - i have a separate table for all three (MTD/QTD/YTD).
These links did not provide the info you need ??
Dynamic Selection
https://community.powerbi.com/t5/Desktop/Dynamic-Metrics-Selection/td-p/605838
https://community.powerbi.com/t5/Desktop/Dynamic-measure-values-based-on-slicer-selection/td-p/41731...
https://community.powerbi.com/t5/Desktop/How-to-display-different-measures-using-a-selector/td-p/131...
@amitchandak : I got the formula now but the problem is it doesnt follow the fiscal calendar. Is there a way around this?
Qtr name is just a display. But for both datesytd and totalytd, you should be able to give year-end date.
https://docs.microsoft.com/en-us/dax/datesytd-function-dax
@amitchandak : Well YTD works great but the QTD is where i am stuck. I have shared the PBIX file the below link. Please see 2018 onwards, QTD seems to calculate calendar quarter and not Fiscal Quarter. Is there a way to fix this?
https://www.dropbox.com/s/e7bdihgnmhiizt0/PBIX%20View.pbix?dl=0
@amitchandak : I think i found a way to calculate Fiscal Quarter. The below formula works great.
QTD
FQTD = CALCULATE (
[Sales total],
FILTER (
ALL ( 'Dates' ),
'Dates'[Fin Year] = VALUES(Dates[Fin Year])
&& 'Dates'[Quarter] = VALUES ( 'Dates'[Quarter] )
&& 'Dates'[Date] <= MAX ( 'Dates'[Date])
))
LYQTD =
CALCULATE (FQTD, sameperiodlastyear(Dates[Date])
Thanks for your help!
Thanks for sharing.
In my case 'Date' is calendar table marked as date and [Date Filer] is joined with sales date. And all the dates in the calendar table cover complete date ranges of sales.
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
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
@amitchandak : Yes i have the Dates table in place and its connected to the fact tables. Although my "Quarter" column is a custom column in dates table and the fact tables. Hope that isn't a problem.
To help you further I need pbix file. If possible please share a sample pbix file after removing sensitive information.Thanks.
My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |