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

Switch/Slicer to toggle between Calendars

Hello - 

I have a common sales data source (date, store, sales $, Units and so on) and a dates table as well. We operate using a fiscal calendar that starts 5/1 and would like a 4-5-4/reporting/retail calendar. Common Measures are YTD, LYTD and Year over Year for Sales, margin, units. Instead of using DAX for YTD filters, we added extra columns in the Date Table to indicate if the date is Fiscal YTD or Reporting YTD, typically a comibnation of lookup values and TODAY() with an If statement, so if the date is within YTD then 1 otherwise blank(). I'd like to figure out how to use a slicer so all the YTD and LYTD measures will toggle between fiscal and reporting calendars. Here is sample data: 

 

DateFiscal YTDReporting YTD
5/1/20181 
5/2/201811
5/3/2018 1
DateSalesQTY
5/1/2018$105
5/2/2018$2010
5/3/2018$3015

 

Common Measures:

Sales

YTD Sales Fiscal Year= Calculate(Sum(SalesTable[Sales]),Fiscal YTD =1) ------expected output $30

YTD Sales Reporting Year= Calculate(Sum(SalesTable[Sales]),Reporting YTD =1) ------ expected output $50

 

Units

YTD Units Fiscal Year= Calculate(Sum(SalesTable[QTY]),Fiscal YTD =1) ------expected output 15

YTD Units Reporting Year= Calculate(Sum(SalesTable[QTY]),Reporting YTD =1) ------ expected output 25

 

 

I sorted out how to use Switch with a measure but that would mean building the independent table for each of the attibrute measures - Margin, Sales, Units, and so on. 

 

All the measures are set up with the same format: Caluclate(sum(),calendar ytd =1)

 

Is there a way to designate a common variable, or parameter or swithc function, so an end user can use a slicer to toggle between the calendar filters of the two calendars. 

 

To further complicate, we have columns for LY Fiscal and LY Reporting, so each of the this year measures  is doubled for a Last Year to Date:

 

Date FiscalFiscal YTDReporting YTDFiscal LYTDReporting LYTD
5/1/20181   
5/2/201811  
5/3/2018 1  
5/1/2017  1 
5/2/2017  11
5/3/2017   1

 

so the date filters of the calculations for LY become (Fiscal LYTD=1) and so on. 

 

One thought, the solution would designate only the 'Fiscal' or 'Reporting' elemend of all the calculations and the slicer would replace that filter value between fiscal and reporting so I create 1 measure per attibute - Sales YTD and Sales LYTD, then depending on the slicer selection the filter (Fiscal YTD =1) would toggle between fiscal and reporting....just a thought.

 

thanks for any help that is out there. Also, I thought of bookmarks and duplicate visuals, but let's be honest, that is a clunky solution. 

6 REPLIES 6
Stachu
Community Champion
Community Champion

why are you not using the DATESYTD? it would make this much more simple with custom calendar e.g.

YTD Sales Reporting Year =
CALCULATE ( SUM ( SalesTable[Sales] ), DATESYTD ( Calendar[Date], "04-31" ) )

should correspond to reporting year starting on May 1st, then you can use SAMEPERIODLASTYEAR to move for LY, end use switch for the measures only



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

I'm not sure I follow. The standard 4-5-4 or Retail calendar has a floating starting date. 

More Info Here

 

So we can't use a designated calendar date for the reporting calendar as it would mitigate the reason for using it. 

 

I'm still not following on how the switch would apply for all the measures. Let's say we have 6 measures: Sales, Sales LY, Units, Units LY, Margin $, Margin $ LY. If those were all in a table for Store 1, Store 2, Store 3 in one summary table, the switch wouldn't work as I am not sure how use switch to refer to the Filter section of the function. 

Stachu
Community Champion
Community Champion

alternatively you could use flags to identify period, eg.
a - YTD
b - reporting YTD

c - LY YTD

d - reporting LY YTD
date would have a corresponding string e.g.

ab

a

c

cd
so if you would filter YTD, you'd pass 'a' parameter to the query that would create a dynamic flag column

 

Measure:=
VAR val = SELECTEDVALUE(Slicer[Flag]) --a VAR temp = FILTER(ADDCOLUMNS(Calendar,"TimeFlag",FIND(val,Calendar[flag],,-1)),[TimeFlag]<>-1) --filters all the rows that have 'a' in the flag column RETURN CALCULATE([Sales],temp)

but I expect performance to be an issue with this approach

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

If I follow the first approach, that would work for one visualization, but the switch is needed across the reporting suite and on each page ideally it would apply to all the visuals. We might have a bar chart for YTD vs. LYTD Sales, then a matrix with sold units YTD vs. LYTD and a guage for Margin performance and so on. I'm looking for a solution that will apply to all of the visuals that incorporate a measure that has a filter like, 'fiscal ytd =1'  and so on. So the switch would modify the measure, would the approach outlined below with  the a, b ,c d facilitate that? 

 

Would we have 1 column with concatenated market flags. So 'a' would be YTD, 'b' would be LYTD, 'c' would be Reporting YTD, 'd' would be Reporting LYTD, so on each day there could be an 'a' or 'ab' or 'c' or 'cd' and so on. That would allow us to refer to a single filtered column instead of referencing 4 different columns? We could be more literal and have 'reportingfiscal ytd' and 'reportingytd' and 'fiscal lytd' and 'reportingfiscal lytd' as indicators in 1 column. Then the slicer could point to a 'contains' function. So as you switch the slicer it would point to a contains 'reporting' or 'fiscal' in the measure and then it would apply to all the measures with that filter. Does that make sense, how would that get set up? 

 

I created a test file here:

https://www.dropbox.com/s/n29wek8bxmc0n31/Test.pbix?dl=0

 

Anonymous
Not applicable

were you able to give the test file a look and provide any insights? 

Stachu
Community Champion
Community Champion

OK, I get it now
if that's the case I would use calendar like this:

DateRepYearRepMonthRepWeek
04/02/2018201811
05/02/2018201811
06/02/2018201811
07/02/2018201811
08/02/2018201811
09/02/2018201811
............
25/02/2018201814
26/02/2018201814
27/02/2018201814
28/02/2018201814
01/03/2018201814
02/03/2018201814
03/03/2018201814
04/03/2018201825
05/03/2018201825
06/03/2018201825
07/03/2018201825
08/03/2018201825
............
04/04/2018201829
05/04/2018201829
06/04/2018201829
07/04/2018201829
08/04/20182018310
09/04/20182018310
10/04/20182018310
11/04/20182018310

then you can use regular DATESYTD for calendar YTD and for reporting YTD use FILTER with appropiate = or <= criteria on RepYear and RepMonth, with LY being RepYear-1

as for the SWITCH - I had in mind something similar to this:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Measures-Titles-Using-SWITCH/td-p/20...



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

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.