Forum Discussion

Ritaf's avatar
Ritaf
Icon for Responsive Resident rankResponsive Resident
4 years ago
Solved

Nested filters Dax

Hi,
I have a table like in the picture,
and I need to visualize multiple measures based on the start/end day without filtering each other.
I prepared 2 calendar tables to achieve this goal and played with removing filters to my needs.
one of the measures has another filter inside, so it ignores "remove filters".
How can I fix it

CALCULATE (
COUNTROWS ( 'Sheet1' ),
ALL ( endCalendar[Date].[Date] ),
FILTER ( 'Sheet1', DATEDIFF ( 'Sheet1'[StartDate], Sheet1[EndDate], DAY ) > 2 )
)

link to Sample pbix 

 



  • I got it!
    It is working with DAX as:

    test3 =
    var _DatedDiffTable =
    ADDCOLUMNS(Sheet1,"@DatesDif",DATEDIFF('Sheet1'[StartDate],'Sheet1'[EndDate],DAY))
    var _FilteredTable =
    FILTER(_DatedDiffTable,
    [@DatesDif] > 2)
    Return
    calculate(COUNTROWS(_FilteredTable),REMOVEFILTERS(endCalendar[Date]))

3 Replies

  • Ritaf , keep those two date tables as independent date tables

     

    Date Range Using 2 slicer =
    var _max1 = minx(allselected(Date1), Date1[Date])
    var _min1 = maxx(allselected(Date1), Date1[Date])

    var _max2 = minx(allselected(Date2), Date2[Date])
    var _min2 = maxx(allselected(Date2), Date2[Date])
    return
    calculate(countrows(Table), Filter(Table,(Table[Start Date] <=_max1 && Table[Start  Date]) >=_min1)  || (Table[End Date] <=_max2 && Table[End Date]) >=_min2) )

     

    • Ritaf's avatar
      Ritaf
      Icon for Responsive Resident rankResponsive Resident

      Hi,
      Thank you for your response, but unfortunately, it isn't working.

      I have updated the sample file with your version of the formula (measure : 

      TestAverage)

      updated sample file 

  • Ritaf's avatar
    Ritaf
    Icon for Responsive Resident rankResponsive Resident

    I got it!
    It is working with DAX as:

    test3 =
    var _DatedDiffTable =
    ADDCOLUMNS(Sheet1,"@DatesDif",DATEDIFF('Sheet1'[StartDate],'Sheet1'[EndDate],DAY))
    var _FilteredTable =
    FILTER(_DatedDiffTable,
    [@DatesDif] > 2)
    Return
    calculate(COUNTROWS(_FilteredTable),REMOVEFILTERS(endCalendar[Date]))