Forum Discussion

finley0726's avatar
finley0726
Frequent Visitor
2 years ago
Solved

Slicer overriding visual level filter (cannot use edit interactions)

I need to display voluntary turnover data - current quarter and last quarter - in the same table visual. I also have a Quarter slicer so that you can filter the visual by each quarter. When Q2 is sel...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,finley0726Hello, amitchandak ,thanks for your concern about this issue.

    Your answer is excellent!
    And I would like to share some additional solutions below.
    I am glad to help you.

    According to your description, you want to display the data of the previous and current quarter of a particular quarter in the date table after the slicer selects the quarter, not only the data of the quarter currently selected by the slicer

    If my understanding is correct, you can refer to my test below

    I created two metrics that calculate the data for the previous and current quarter of the quarter

    and only the previous quarter's data (calculating the data that fits within this timeframe and marking it as 1)

    Here are the results of my tests

    What is important is that: I did not create a relationship between the calendar table “time” and the data table “Sales_Table” as a slicer filter field, because that would have resulted in the direct filtering of the field that you are experiencing.

    I use the result of the decision to create the measure value to filter the data, which acts as a slicer filter (at this point, the slicer only serves to provide the filter value, and has no actual filtering effect, since there is no relationship between the tables).

    At this point in the visual will only display M_Current&prior results for the value of 1, the advantage of doing so is that you can set your own needs according to the scope of screening, such as filtering the last quarter and the quarter's data or only filtering the last quarter's data.

    Here is the DAX code:

    M_Current&prior = 
     VAR maxDate=MAX('Time'[Date])
     //maxDate shows the last day of the selected quarter.
     VAR minDate=EOMONTH(maxDate,-6)+1
     //minDate shows the first day six months before maxDate, which is the first day of the previous quarter
     VAR result=
     IF(SELECTEDVALUE('Sales_Table'[Date])>=minDate&&SELECTEDVALUE(Sales_Table[Date])<=maxDate,
     1,0)
    
     RETURN result
    
    
    M_prior quarter = 
     VAR maxDate=MAX('Time'[Date])
     //maxDate shows the last day of the selected quarter.
     VAR minDate=EOMONTH(maxDate,-6)+1
     //minDate shows the first day six months before maxDate, which is the first day of the previous quarter
     VAR minDateEnd=EOMONTH(maxDate,-3)
     VAR result=
     IF(SELECTEDVALUE('Sales_Table'[Date])>=minDate&&SELECTEDVALUE(Sales_Table[Date])<=minDateEnd,
     1,0)
    
     RETURN result
    

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

    Best Regards,

    Carson Jian,

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.