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
Anonymous
Not applicable

how to filter LOOKUPVALUE

I have a table like the following:

Week KeyWeek LabelYear
2019.1a2019
2020.2b2020
2021.1a2021

 

I have a line chart with [Week Label] (**not [Week Key]**) on the x-axis.  I want to return the cumulative sum of some numerical column in my fact table for [Year] = 2020.  How can I do so?  I have tried the following, but DAX is saying that, for the LOOKUPVALUE portion of the code, "a table of multiple values was supplied where a single value was expected."  So, I must not be filtering 'Dimension Week' correctly in the LOOKUPVALUE portion of the code.

 

 

Cumulative Sum of Sales - 2020 =
VAR __given_week =
    MAX('Dimension Week'[Week])

VAR __corresponding_week_key =
    CALCULATE(
        LOOKUPVALUE(
            'Dimension Week'[Week Key]
            ,'Dimension Week'[Week]
            ,__given_week
        )
        ,'Dimension Week'[Year] = "2020"
    )

RETURN
    CALCULATE(
        [Sum of Sales - Year 2020]
        ,ALLEXCEPT(
            'Dimension Week'
            ,Dimension Week'[Year]
        )
        ,'Dimension Week'[Week Key] <= __corresponding_week_key 
    )

 

2 REPLIES 2
Anonymous
Not applicable

I think I solved my problem.  I was misunderstanding the syntax for LOOKUPVALUE.

 

VAR __week_key =
    LOOKUPVALUE(
        'Dimension Week'[Week Key]
        ,'Dimension Week'[Week]
        ,__max_week
        ,'Dimension Week'[Fiscal Year Relative Category]
        ,"FY-2"
)

Thanks for your update. As the issue is resolved. I will close this thread.

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.