Forum Discussion

wpf_'s avatar
wpf_
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

How to use two date slicers on different table visuals?

I need to build a report where it compares the same month from different years and the third table shows the percent change.  All data is from the same table.  so for example:

 

DateABCTotal
4/1/20194565678779
4/2/201936251475
4/3/2019748596255
    1109
     
     
DateABCTotal
4/1/2020548536175
4/2/2020454337125
4/3/2020819237210
    510
     
     
DateABCTotal
Wed10%8.50%6.30%7.90%
Thurs5.20%4.10%9.60%6.30%
Fri5.80%2.90%1.80%3.90%
    5.10%

 

I tried using two seperate slicers with each one filtering a different table visual.  But that doesn't seem to work, it comes up blank.  I guess it's doing an AND operation on the same data set.  Is there any way to do this in BI without creating another table?  And how would i create the percent change table with the percent change values?  Thanks. 

 

 

 

  • wpf_ As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

    https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-calculations/

     

    and from this new date table, you can easily get a previous year sum for the same month and then calculate the %, add following measure

     

    Current = SUM ( Table[Value] )
    
    Prev = CALCULATE ( [Current], DATEADD( DateTable[Date], -1, YEAR ) )
    
    % Diff = DIVIDE ( [Current] - [Prev], [Prev] ) 

     

    Not sure if you data exactly looks like the way you showed, if yes, then you need to unpivot your data

     

    - transform data
    - select date column 
    - right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
    - close and apply

    - set relationship date from the transaction table with the date table added earlier.
    To visualize,
    - matrix visual:
    - add date from date table on rows,
    - add attribute on columns
    - add above measure on values


     

    I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    ⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡

    , 

3 Replies

  • wpf_ As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

    https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-calculations/

     

    and from this new date table, you can easily get a previous year sum for the same month and then calculate the %, add following measure

     

    Current = SUM ( Table[Value] )
    
    Prev = CALCULATE ( [Current], DATEADD( DateTable[Date], -1, YEAR ) )
    
    % Diff = DIVIDE ( [Current] - [Prev], [Prev] ) 

     

    Not sure if you data exactly looks like the way you showed, if yes, then you need to unpivot your data

     

    - transform data
    - select date column 
    - right-click, unpivot other columns it will add two columns, attribute, and value, rename these as per your requirement
    - close and apply

    - set relationship date from the transaction table with the date table added earlier.
    To visualize,
    - matrix visual:
    - add date from date table on rows,
    - add attribute on columns
    - add above measure on values


     

    I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    ⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡

    , 

    • wpf_'s avatar
      wpf_
      Icon for Post Prodigy rankPost Prodigy

      parry2k ,

       

      Thanks very much, i just tried the prev measure and it worked!

      Just one issue though.  What if i wanted not to go just one year previous in exact calendar date (4/1/2020 to 4/1/2019), but wanted to go one year previous to that same first weekday of that month  ( Wednesday 4/1/2020 to Wednesday 4/3/2019) ?  Thanks. 

      • wpf_'s avatar
        wpf_
        Icon for Post Prodigy rankPost Prodigy

        parry2k ,

         

        i was able to get to the previous year to the first day of that month using DAY intervals in DATEADD function (minus or plus a few days).  I will look into using a variable for the interval days and use a slicer to change the variable.  If you have a better solution please let me know. Thanks.