Forum Discussion

GKJARC's avatar
GKJARC
Icon for Resolver I rankResolver I
4 years ago
Solved

Showing rows in table visual depending on selected date range

Hi!

 

In a table visual, I'm trying to show only the rows where there is an overlap between the ValidFrom to ValidTo, and the selected date range.
The Date in the date range slicer comes form an unrelated calendar table.

 

 

So with the above selected date range, only the rows marked here as '1' should appear in the table visual in Power BI:

 

 

The first 4 columns all come from a single table.

  • GKJARC , Try a measure like

    Measure =
    VAR _min = MINX(allselected(Dates) ,Dates[Date])
    VAR _max = MAXX(allselected(Dates) ,Dates[Date])
    return
    if(max(Table[Valid From]) <= _max && max(Table[Valid To]) >=_min , 1,0)+0

     

2 Replies

  • GKJARC , Try a measure like

    Measure =
    VAR _min = MINX(allselected(Dates) ,Dates[Date])
    VAR _max = MAXX(allselected(Dates) ,Dates[Date])
    return
    if(max(Table[Valid From]) <= _max && max(Table[Valid To]) >=_min , 1,0)+0

     

    • GKJARC's avatar
      GKJARC
      Icon for Resolver I rankResolver I

      Thanks amitchandak , that seems to work!
      I used SWITCH-statements intstead of IF-statement hoping to improve performance since I have 3 conditions, and the table visual that this measure applies to is relatively large.
      When I add the measure as a filter on the table visual level (Measure <> 0), then Power BI can handle it in terms of memory.

      One more question, what is the function of the +0 at the end of the measure?