Forum Discussion

Prabha45's avatar
Prabha45
Helper III
2 years ago
Solved

Selectedvalue blank

Hi All, I got stuck with the selected value DAX. Its returns blank like the below image. What am I missing. Please help me. I know this looks silly but I don't understand the error. TIA ...
  • Ritaf1983's avatar
    2 years ago

    Hi Prabha45 
    The formula returns blank because you are using date hierarchy in your slicer. 

    So you didn't select a date, you selected the year and month.

    Modify your measure according to the possible selections, for example :

    slected year_month = SELECTEDVALUE('Dates'[Date_].[Year])&"-"&SELECTEDVALUE('Dates'[Date_].[Month])
    ( you can add a quarter and day if you need them too)
    result :

     

     

    PBIX is attached

    If this post helps, then please consider Accepting it as the solution to help the other

    members find it more quickly

     

     

  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    Hi Prabha45 
    1. You can't use the operator "<>" to compare strings, and month in this case is a string.
    2. if you nee and as an operator you should use "&&" and not "&"
    modify your formula to :

    Measure =
    Var selectyear = Selectedvalue(Dates[Date_].[Year])
    Var selectmonth = Selectedvalue(Dates[Date_].[month])
    Var ans = If(selectyear =2023 && selectmonth in {"july","August","September","October","November","December"},
                       
                       [plan],[actual])
                         return ans

    The updated pbix is attached. 
    (i used just strings for plan and actual )

    If this post helps, then please consider Accepting it as the solution to help the other

    members find it more quickly

  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    Hi Prabha45 
    I recommend just to work with a "Date" type slicer ...

    working with hierarchies here seems to me too many "woodo dances" for the very simple scenario 

    If this post helps, then please consider Accepting it as the solution to help the other

    members find it more quickly