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
LisaB
Helper III
Helper III

SELECTEDVALUE and SWITCH doesn't return value

Hi,

 

I have a table where I want to return exchange rates based on a selected value.

 

Table LCY is used as a slicer and only single selection is allowed. I have multiple exchange rate tables and there is relationship created from each one of them to my transaction table.   

 

I have created a column and this is my formula but it doesn't return any values at all.

 

 

Exchange Rate = 

VAR  Selection =

    SELECTEDVALUE ( LCY[Currency Code])

RETURN

    SWITCH (

        TRUE (),
        Selection = "SEK", RELATED(Currenices_SE[ExchangeRateAmt]),

        Selection = "AUD", RELATED(Currenices_AU[ExchangeRateAmt]),
        
        Selection = "DKK", RELATED(Currenices_DK[ExchangeRateAmt]),

        Selection = "USD", RELATED(Currenices_US[ExchangeRateAmt]),
        
        Selection = "EUR", RELATED(Currenices_NL[ExchangeRateAmt])
    )

 

 

 Could you please advise? 🙂

 

Thanks!

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @LisaB ,

In your sample, if Exchange Rate is a measure, you can use MAX function to return the current value.

 

vkalyjmsft_0-1637030321848.png

 

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @LisaB ,

In your sample, if Exchange Rate is a measure, you can use MAX function to return the current value.

 

vkalyjmsft_0-1637030321848.png

 

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PaulDBrown
Community Champion
Community Champion

Do you mean a column as in a calculated column in a physical table? If so, it won't work: physical tables are "calculated" when the model is loaded and are oblivious to slicers.

You can however use it as a measure in a table visual





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi Paul,

 

I don't really follow. Yes, it is a column but when creating a measure instead I get an error saying following:

 

"The column either doesn't exist or does not have a relationship"

LisaB_0-1636911191644.png

 

Greg_Deckler
Super User
Super User

@LisaB What does your data model look like? RELATED only works across 1 to many relationships and only returns values from the 1 side of the relationship.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

This is how it looks like. I tried only RELATED and it returns the correct values for each currency table (pleae disregard the misspelling 🙂). 

 

LisaB_0-1636887190917.png

 

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.