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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
junglejimsvet
Helper I
Helper I

Can't get SELECTEDVALUE to work within a VAR

Hi All,

 

It feels simple but I have searched for a few hours to no avail!

 

I am trying to use the selectedvalue function to inform a variable which is then used in a measure.   Basically when I replace the selectedvalue with text, then it all works e.g. Intype="Test" works fine, but if I use Selectedvalue aligned to a field which produces "Test" it does not.

 

I am assuming the ourput of the Selected value needs formatting to be able to be used in the measure but I'm not sure how.

 

Massively grateful for any pointers!

 

 

 

Interactions matching Enterprise Interaction Type =
VAR
IntType=SELECTEDVALUE(Interactions[Enterprise Interaction Type])
RETURN

CALCULATE(
    [23 Call Name],
    'Interactions'[Enterprise Interaction Type] IN { IntType }
)
6 REPLIES 6
Anonymous
Not applicable

Hi@junglejimsvet 

What's the default value you're planning to pass in Interactions[Enterprise Interaction Type] ? the table you refer has only one value or multiple values, it will return blanks if multi availble.

Hi there LW,

I've not used a default value as I am happy to have zero if there are multiple values.

 

  • Basically I  have a slicer based on Interactions[Enterprise Interaction Type]) which I have made not interact with a data table
    • Lets say I select "Impact" from the drop down (so a text value)
  • If I then use SELECTEDVALUE(Interactions[Enterprise Interaction Type]) I get "Impact" when I display it on a  card as it is the only value in the column
  • What I am trying to do is have a  complete list of customers and show which ones have been interated with on the subject "Impact".   If I just use a slicer, it hides the people who I have not seen, but I need zeros next to them
  • If I use the word "Impact" in the dax it works fine, but if I use SELECTEDVALUE(Interactions[Enterprise Interaction Type])  it does not work, even though it looks to be outputting the same text.

 

Desired output:

Discussion Topic Selected in Slicer:  "Impact"

Name      Interactions

Jim            2

John         0

Alex          1

 

I can't find a way to make John stay in the table as if I filter to "Impact" it just excludes him (show items with no data does not work either).
 
Any thoughts gratefully received:)
Anonymous
Not applicable

hi @junglejimsvet 

Found this post, very much related to what you're trying to do. You need to tweak your DAX code.

https://community.powerbi.com/t5/Desktop/Use-selectedvalue-in-a-measure/td-p/483456

In order to understand SELECTEDVALUE functionality;

https://docs.microsoft.com/en-us/dax/selectedvalue-function

 

Thanks

 

junglejimsvet
Helper I
Helper I

Just for further context, I am essentially trying to replicate the "Difference from Filtered Value" Quick measure except using a dynamic filter. 

 

 

Many thanks, its a really good page.  Unfortunately it does not look like it is possible to do what I need to do - I think VAR can only be used with numeric fields  so I can't put text in there (although I can use variales with typed text rather than text producted from a formula) 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors