Forum Discussion

MauroMa's avatar
MauroMa
New Member
1 year ago

SelectedValue in a Lookupvalue

Hi!

I have a problem that I do not seem to be able to resolve.

 

I have a table call Moneda that looks like this:

 

Moneda
ARS
USD

 

I have a lookupvalue measurement that looks like this:

= LOOKUPVALUE('TC'[ARS],TC[Fecha],DATE(2025,1,1),'TC'[Moneda Objetivo],SELECTEDVALUE('Moneda'[Moneda]),TC[Moneda],'Forecast/Actual'[00],1)

 

I basically want to have a slicer where I can select "Moneda" and that should impact the Lookupvalue result. The problem is that it is not working... If I replace SELECTEDVALUE('Moneda'[Moneda]) for a hardcoded "ARS" or "USD" the measurement will work as I want it to, but when I add the SELECTEDVALUE('Moneda'[Moneda]), it will default in the alternative result "1".

 

The slicer is set to have only one option selected. Tables are related and I have changed some relations to see if that was the problem but it does not seem to work.

3 Replies

  • LOOKUPVALUE is something to ease Excel users into Power BI.  You should not use it unless you really really have to.

     

    Is your Moneda table a disconnected table?  

     

    Use TREATAS to transfer filters from one table to another.

  • Hi MauroMa 

     

    Based on your formula, what you're trying to create is  not a measure but a calculated column. Calculated tables and columns are not aware of any slicer selection. They don't know that a  value has been selected from a slicer thus your search criterion for 'TC'[Moneda Objetivo] is actually blank so your formula returns the alternate result 1.

    It is unclear how you want ARS is to be aggreated so this is just a sample measure based on your formula and assuming ther are no relationshiops between TC and Moneda and Forecast/Actual and TC:

    CALCULATE (
        SUM ( 'TC'[ARS] ),
        KEEPFILTERS ( TC[Fecha] = DATE ( 2025, 1, 1 ) ),
        KEEPFILTERS ( TREATAS ( VALUES ( 'Moneda'[Moneda] ), 'TC'[Moneda Objetivo] ) ),
        KEEPFILTERS ( TREATAS ( VALUES ( 'Forecast/Actual'[00] ), TC[Moneda] ) )
    )
    

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi   MauroMa 

    I tried something simplified, which seems work. 

     

     

    Can you check if your formula is used as a calculated column or as a measure
     
    If it is used as a calculated column, this is the expected outcome because calculated columns cannot be dynamically updated by slicer options. 
     
    If it is used as a measure, it might be due to the part "TC[Moneda],'Forecast/Actual'[00]". 'Forecast/Actual'[00] should provide a specific value for search too. You might need to use some function to wrap the 'Forecast/Actual'[00] column. 

     

    If possible, can you show the current model relationships between tables? When relationships are appropriate, sometimes using other DAX functions may have a better performance. 

     

    Best Regards,
    Jing