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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jgorigo
Regular Visitor

Lookupvalue DAX with a table multiples values

Hello everyone. I'll really appreacite your help.

I have a table named uf_prosp with data for bussiness day (_plazo) and interest rates (_tasas) for every end of month (_fecha_curva). 

The column _fecha_curva has data for 12/30/2021, 01/31/2022 and 02/28/2022.

How can i say to this measure to look for to VAR y1 and VAR y2 accordind to date(2021,12,30)

 

FD =
VAR fecha_curva = date(2021,12,30)

VAR x1 = 1

VAR x2 = 15
VAR y1 = LOOKUPVALUE(uf_prosp[_tasas],uf_prosp[_plazo],x1)
VAR y2 = LOOKUPVALUE(uf_prosp[_tasas],uf_prosp[_plazo],x2)

RETURN y1 * y2

 

I get this error message

jgorigo_1-1659359830711.png

 

jgorigo_0-1659359691376.png

Thanks.

1 ACCEPTED SOLUTION
Barthel
Solution Sage
Solution Sage

Hey,


The LOOKUPVALUE does not take the date into account, so there are multiple results (3 in total, 1 for each date). This is not allowed. A measure can only return 1 value. You need to add a filter context for the correct date. This is best done with a CALCULATE function. Always try to work with CALCUATE as much as possible and avoid LOOKUPVALUE, this is best practice.

FD =
VAR fecha_curva =
    DATE ( 2021, 12, 30 )
VAR x1 = 1
VAR x2 = 15
VAR y1 =
    CALCULATE (
        SELECTEDVALUE ( uf_prosp[_tasas] ),
        KEEPFILTERS ( uf_prosp[_plazo] = x1 ),
        KEEPFILTERS ( uf_prosp[fecha_curva] = fecha_curva )
    )
VAR y2 =
    CALCULATE (
        SELECTEDVALUE ( uf_prosp[_tasas] ),
        KEEPFILTERS ( uf_prosp[_plazo] = x2 ),
        KEEPFILTERS ( uf_prosp[fecha_curva] = fecha_curva )
    )
RETURN
    y1 * y2

 

View solution in original post

2 REPLIES 2
Barthel
Solution Sage
Solution Sage

Hey,


The LOOKUPVALUE does not take the date into account, so there are multiple results (3 in total, 1 for each date). This is not allowed. A measure can only return 1 value. You need to add a filter context for the correct date. This is best done with a CALCULATE function. Always try to work with CALCUATE as much as possible and avoid LOOKUPVALUE, this is best practice.

FD =
VAR fecha_curva =
    DATE ( 2021, 12, 30 )
VAR x1 = 1
VAR x2 = 15
VAR y1 =
    CALCULATE (
        SELECTEDVALUE ( uf_prosp[_tasas] ),
        KEEPFILTERS ( uf_prosp[_plazo] = x1 ),
        KEEPFILTERS ( uf_prosp[fecha_curva] = fecha_curva )
    )
VAR y2 =
    CALCULATE (
        SELECTEDVALUE ( uf_prosp[_tasas] ),
        KEEPFILTERS ( uf_prosp[_plazo] = x2 ),
        KEEPFILTERS ( uf_prosp[fecha_curva] = fecha_curva )
    )
RETURN
    y1 * y2

 

Hi.

Now it works perfec. Thank so much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.