Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Using a single slider for four dates column

Hi All,

 

I have fours Dates columns in table

Like

AFromDate, BTodate, CFromDate,DTodate

 

The issue is i want to use single date to selecte all the period within these four dates.

 

I have created below Measure and used in visual level filters and set to 1.

It is working fine for two columns but not for all four columns.

Measure =
IF (
SELECTEDVALUE ( 'A'[SrFromDate] ) <= MAX ( DimDate[FullDateAlternateKey] )
&& SELECTEDVALUE ( 'B'[SrToDate] ) >= MIN ( DimDate[FullDateAlternateKey] )
&& SELECTEDVALUE ( 'A'[TsFromDate] ) <= MAX ( DimDate[FullDateAlternateKey] )
&& SELECTEDVALUE ( 'B'[TsToDate] ) <= MAX ( DimDate[FullDateAlternateKey] ),
1,0
)
 
Any correction required to make workable for all four columns?
Looking forward to solutions from Masters.
 
Regards,
 
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    It is by design.

    You are using SELECTEDVALUE ( 'TableA'[TsFromDate] ) and SELECTEDVALUE ( 'TableA'[TsToDate] ) in the formula.

    Remember that SELECTEDVALUE function rely on context, you will need the columns in visual.

     

    Best Regards,

    Jay

3 Replies

  • lukiz84's avatar
    lukiz84
    Memorable Member

    Can you show some sample rows where it doesn't work?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Lukiz for response.

       

      Now that issue has been resolved.

       

      Can you help me to resolve below DAX.

       

       

      TS Count =

      var flag =
      IF (
      SELECTEDVALUE ( 'TableA'[TsFromDate] ) <= MAX ( DimDate[FullDateAlternateKey] )
      && SELECTEDVALUE ( 'TableA'[TsToDate] ) >= MIN ( DimDate[FullDateAlternateKey] )
      ,
      1,0
      )
      var TsCount =
      IF (
      flag = 1, CALCULATE(COUNT('TableA'[TS_ID])) + 0,0

      )
      return TsCount
       
      Right now, Current selection in slicer is september, 2022.
      In my grid, when i put both columns so above Dax measure works fine and calculate count as required as shown below.
       

       

      But when i remove date columns in grid so it does not work and count is 0.

      I dont need to show dates in Grid as per requirment.

       

      Any suggestion would be highly appreciated.

       

       

       

       

       

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    It is by design.

    You are using SELECTEDVALUE ( 'TableA'[TsFromDate] ) and SELECTEDVALUE ( 'TableA'[TsToDate] ) in the formula.

    Remember that SELECTEDVALUE function rely on context, you will need the columns in visual.

     

    Best Regards,

    Jay