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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
NSC7
Helper I
Helper I

SELECTEDVALUE on a slicer returning Blank

Hi,

 

I am using SELECTEDVALUE to create a Dynamic column, but Selected value is returning blank and because of that Switch function is not giving proper result.

 

IdenYear =

VAR SelYear= SELECTEDVALUE('Calendar'[Year2])
RETURN 
SelYear
 
NSC7_0-1706068915752.png

 

Based on the selectedvalue from filter I want to retrun below custom column value.

IdenYear =
VAR SelYear= SELECTEDVALUE('Calendar'[Year2])
RETURN
SWITCH(TRUE(),SelYear='Calendar'[Year2],"Y",SelYear-1='Calendar'[Year2] && MONTH('Calendar'[Date])=12,"Y","N")
NSC7_1-1706069029217.png

Thanks

1 ACCEPTED SOLUTION

HI @Ahmedx,

AFAIK, current power bi does not support to create dynamic calculated column/table based on filter effects. They do not work on the same level and you can't use the child to effect its parent level.

For this scenario, I think it should be related selectedvalue function itself. It not suitable to handle multiple values.
When you selected on the slicer, it has match with multiple rows and will return blank if you not enabled the alternateResult option to process. (since calculate column not able to receiver the filter effects from slicer, its row contents show match with whole table records)

SELECTEDVALUE function - DAX | Microsoft Learn

Notice: the data level of power bi(from parent to child level)

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
Ahmedx
Super User
Super User

this is because you have the date as a hierarchy, you need to disable it and create separate columns for the year

 

I am using Year2 column in the slicer and in selectedvalue.

 

Year2 = 'Calendar'[Date].[Year]
 
VAR SelYear= SELECTEDVALUE('Calendar'[Year2])
 
I have also tried Year2 as Year2 = YEAR('Calendar'[Date]) but it still does not work.

see how to disable hierarchies
and create a year column like this
Year = YEAR(Date[Date])

Screenshot_1.pngScreenshot_2.png

 

It is still not working, I have disbled the setting at Global and Local both levels as you explained above and created Year2 column like 

 

Year2 = YEAR('Calendar'[Date])

 

NSC7_0-1706071741424.png

 

NSC7_1-1706071807758.png

 

 

HI @Ahmedx,

AFAIK, current power bi does not support to create dynamic calculated column/table based on filter effects. They do not work on the same level and you can't use the child to effect its parent level.

For this scenario, I think it should be related selectedvalue function itself. It not suitable to handle multiple values.
When you selected on the slicer, it has match with multiple rows and will return blank if you not enabled the alternateResult option to process. (since calculate column not able to receiver the filter effects from slicer, its row contents show match with whole table records)

SELECTEDVALUE function - DAX | Microsoft Learn

Notice: the data level of power bi(from parent to child level)

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

share the file to help

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.