Forum Discussion

fabo's avatar
fabo
Icon for Advocate III rankAdvocate III
6 years ago
Solved

Interaction between date slicer and line chart

Hi everyone.

I need a line chart to be responsive when one date is selected from a date slicer.  For example, if the selected date is december 31st, 2019, line chart should look like:

But, if I change the date to may 31st, 2019, line chart should be:

I was able to get this done but I'm not really sure if my approach is good.  Maybe there is a better one, more efficient.  So please I need your comments and suggestions.

 

My approach

The model:

 

As you can see I created a disconnected table for the date slicer.  The measures I used are:

Selected Date = // Get what date is selected from the slicer
  SELECTEDVALUE(Date_Slicer[Date]) 
Total Qty = // Measure to be used in any chart except the line chart
  CALCULATE(
    SUM(Fact_Table[Qty])
  )
 Total Qty Line Chart = // Measure to be used only in the line chart
  CALCULATE(
    [Total Qty];
    FILTER(
      ALL('Date'[Date]);
      'Date'[Date] <= [Selected Date]
    )
  )
What do you think, guys?  Is it a good approach?  Can you figure out a better solution?
 
Fabo.
  • Hi fabo ,

     

    This is a good approach, however you can also try one of other two options to not make another unrelated table:

    • Make the slicer a Before or a Between slicer and that will return the values based on that selection
    • Ohter option is to make the relationship between Date and Fact Table disable and the making use of the USERELATIONSHIP function create the measure that need the active relationship between both tables and use the same function as you have but with only one date table.

    Regards,

    MFelix

2 Replies

  • Hi fabo ,

     

    This is a good approach, however you can also try one of other two options to not make another unrelated table:

    • Make the slicer a Before or a Between slicer and that will return the values based on that selection
    • Ohter option is to make the relationship between Date and Fact Table disable and the making use of the USERELATIONSHIP function create the measure that need the active relationship between both tables and use the same function as you have but with only one date table.

    Regards,

    MFelix

    • fabo's avatar
      fabo
      Icon for Advocate III rankAdvocate III

      Hi MFelix .

      I really appreciate your comments.  Both options are better, and the second one fits exactly to what I need.  I will definetly use it in my reports.

      Thank you so much!

      :smileyvery-happy: