Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

SELECTEDVALUE AS FILTER

Good afternoon everyone,

 

I have a table named (main) with two columns(date1 and date2), we could say date1 is the starting date and date2 is the finishing one.

 

Also, I have a date table I have created to connect the data from the main table to this one.

 

The purpose of my question is the next: 

 

I want to create a date filter where I can range the dates and count the rows from the main table which have the dates (date1 and date2) between the dates I have selected. Up to this point, everything is right I'm obtaining the results I'm looking for.

 

But everything change when I want to count the rows from the main table whose date1 dates are < date selected in the filter..

 

I have tried the following DAX: 

RESULTS < =
VAR SELECTEDM = SELECTEDVALUE('CALENDAR'[Date])
RETURN
COUNTROWS(FILTER('MAIN';'MAIN'[DATE1]<SELECTEDM))
 
DAX  function is working but it's not throwing back the correct result 
 
Any help?
 
Kind Regards,
 
Adrian
  • Hi Anonymous ,

     

    You could try the following DAX:

    RESULTS < =
    VAR SELECTEDM =
        MINX ( ALLSELECTED ( 'CALENDAR'[Date] ); 'CALENDAR'[Date] )
    RETURN
        COUNTROWS ( FILTER ( 'MAIN'; 'MAIN'[DATE1] < SELECTEDM ) )

     

1 Reply

  • v-eachen-msft's avatar
    v-eachen-msft
    Community Support

    Hi Anonymous ,

     

    You could try the following DAX:

    RESULTS < =
    VAR SELECTEDM =
        MINX ( ALLSELECTED ( 'CALENDAR'[Date] ); 'CALENDAR'[Date] )
    RETURN
        COUNTROWS ( FILTER ( 'MAIN'; 'MAIN'[DATE1] < SELECTEDM ) )