Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

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

  • Stachu's avatar
    Stachu
    Icon for Community Champion rankCommunity 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

    • Anonymous's avatar
      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's avatar
        Stachu
        Icon for Community Champion rankCommunity 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/200718