Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Prabha45
Helper III
Helper III

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

Pic.jpg

3 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

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 :
Ritaf1983_1-1701449990549.png

 

 

PBIX is attached

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

members find it more quickly

 

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

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
Ritaf1983_0-1701532843951.png

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

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

Ritaf1983_0-1701535458531.png

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

5 REPLIES 5
Prabha45
Helper III
Helper III

Thanks @Ritaf1983 
It worked, I'm trying to show value PLAN if month greater 2023 June based on the date hierarchy.
Measure = 
Var selectyear = Selectedvalue(dim_date[date].[Year])
Var selectmonth = Selectedvalue(dim_date[date].[month])
Var ans = If(selectyear =2023 & selectmonth > "June",
                     [PLAN],
                     [ACTUAL])
The above measure throws an error. Doesn't support comparing values of type integer with values type text.
Please help on this

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
Ritaf1983_0-1701532843951.png

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thank you @Ritaf1983 
Can we do it in reverse. Show data [Actual] if selected date less than 2023 June. Going forward data gets updated for 2024,2025....
My data starts from 2020.

 
Var ans = If(selectyear =2023 && selectmonth in {"January","February","March","April","May","June"} &&  If( selectyear = 2022 && selectmonth in {"January" ............"December"}
&&  If(selectyear = 2021   && selectmonth in  {"January" ............"December"}
&& If(selectyear = 2020 && selectmonth {"January" ............"December"}
 
                   [actual],[Plan])
                     return ans

Is this the only way ?

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

Ritaf1983_0-1701535458531.png

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

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 :
Ritaf1983_1-1701449990549.png

 

 

PBIX is attached

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

members find it more quickly

 

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors