Forum Discussion

mohammadrafic's avatar
5 years ago
Solved

calendar selectedvalue compare another table

 

hi , i have calendar table and used in below calendar slicer. how can i get the selectedvalue which is highlight in red. 

and it shoud compare with another table date column which is available or not.

 

if user selects the future date from the below calendar which is not available in another table. message should show or empty the visual. please help me with dax function..

 

note: i dont want to use the dropdown slicer option. same type i need.

 

 

  • ITManuel's avatar
    ITManuel
    5 years ago

    Hi  ,

     

    I tried the following:

    - Calendar is your Calendar table

    - Calendar1 is your other table which contains the dates to check existence in your selection

     

     

    1. Create measure to return Selected Max Date 

     

     

    SelectedMaxDate = 
    VAR SelectedMaxDate = 
        CALCULATE(
            MAX('Calendar'[Date]),
            ALLSELECTED('Calendar')
        )
    RETURN
    SelectedMaxDate

     

     

     

    1. Create measure to check weather Selected Max Date is part of Calendar1. If yes, return "" otherwise return "Error".

     

     

    CheckDate = 
    VAR CheckDate = 
        CONTAINSROW(VALUES(Calendar1),[SelectedMaxDate])
    VAR Result =
        IF(
            CheckDate,
            "",
            "Error"
        )
    RETURN
        Result

     

     

     

    PBiX file under the link below:

    https://we.tl/t-GDrBRxvXYC

     

    Best regards

     

6 Replies

    • mohammadrafic's avatar
      mohammadrafic
      Helper I

      it is bring end of the year date...it is not working .. and i need to compare that date with another table date is available or not.

       

       

       

       

      or can you tell me how to hide the future dates from the abve pls

      • ITManuel's avatar
        ITManuel
        Responsive Resident

        Hi  ,

         

        I tried the following:

        - Calendar is your Calendar table

        - Calendar1 is your other table which contains the dates to check existence in your selection

         

         

        1. Create measure to return Selected Max Date 

         

         

        SelectedMaxDate = 
        VAR SelectedMaxDate = 
            CALCULATE(
                MAX('Calendar'[Date]),
                ALLSELECTED('Calendar')
            )
        RETURN
        SelectedMaxDate

         

         

         

        1. Create measure to check weather Selected Max Date is part of Calendar1. If yes, return "" otherwise return "Error".

         

         

        CheckDate = 
        VAR CheckDate = 
            CONTAINSROW(VALUES(Calendar1),[SelectedMaxDate])
        VAR Result =
            IF(
                CheckDate,
                "",
                "Error"
            )
        RETURN
            Result

         

         

         

        PBiX file under the link below:

        https://we.tl/t-GDrBRxvXYC

         

        Best regards