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
Blindreaper
New Member

Lookup on multiple criteria

Hi all,

 

I am pretty new to Power Bi and DAX and I'm really stuck with a way to get the data I want.

 

Two things I need to calculate are:

1.Year on Year sales increase/drop.
In the first row I have sales for 2014, store ID 22555. This needs to be compared to store 22555 from 2015.

2. Week by week, Year on Year. 

So,  2014 week 30 store 22555 compared with 2015 week 30 store 22555.

 

YearPeriodWeekStore
ID
Store NameRoyalty
Sales
201473022555London 1£2,100.00
201473133666London 2£3,110.00
201483222555London 1£3,204.00
201483333666London 2£5,500.00
201573022555London 1£1,000.00
201573133666London 2£2,000.00
201583222555London 1£3,000.00
201583333666London 2£2,000.00
201673022555London 1£5,000.00
201673133666London 2£2,000.00
201683222555London 1£500.00
201683333666London 2£6,000.00
201773022555London 1£2,000.00
201773133666London 2£3,000.00
201783222555London 1£2,200.00
201783333666London 2£2,500.00

 

I have tried calculated columns with Lookupvalue on multiple criteria but I am getting error "multiple values returned".

 

Help would be much appreciated.

4 REPLIES 4
Eric_Zhang
Employee
Employee

@Blindreaper

For year comparing to year, you can create a measure as below and put it in a line and stacked column chart.

sales increment precentage by year =
VAR salesInPreYear =
    CALCULATE (
        SUM ( Table1[Royalty Sales] ),
        FILTER ( ALLSELECTED ( Table1 ), Table1[Year] = MAX ( Table1[Year] ) - 1 )
    )
RETURN
    DIVIDE ( SUM ( Table1[Royalty Sales] ) - salesInPreYear, salesInPreYear )

Capture.PNG

 

For comparing week to previous year's week, you could follow the same pattern of year to year, just add an extra year slicer.

sales increment precentage by yearWeek =
VAR salesInPreYearWeek =
    CALCULATE (
        SUM ( Table1[Royalty Sales] ),
        FILTER (
            ALLSELECTED ( Table1 ),
            Table1[Week] = MAX ( Table1[Week] )
                && Table1[Year]
                    = MAX ( Table1[Year] ) - 1
        )
    )
RETURN
    DIVIDE (
        SUM ( Table1[Royalty Sales] ) - salesInPreYearWeek,
        salesInPreYearWeek
    )

Capture.PNG

Thank you for your reply @Eric_Zhang

 

Is there any way to create calculated colums which would show both values in the table?

Blindreaper
New Member

Hi all,

 

I am pretty new to Power Bi and DAX and I'm really stuck with a way to get the data I want.

 

Two things I need to calculate are:

1.Year on Year sales increase/drop.
In the first row I have sales for 2014, store ID 22555. This needs to be compared to store 22555 from 2015.

2. Week by week, Year on Year. 

So,  2014 week 30 store 22555 compared with 2015 week 30 store 22555.

 

YearPeriodWeekStore
ID
Store NameRoyalty
Sales
201473022555London 1£2,100.00
201473133666London 2£3,110.00
201483222555London 1£3,204.00
201483333666London 2£5,500.00
201573022555London 1£1,000.00
201573133666London 2£2,000.00
201583222555London 1£3,000.00
201583333666London 2£2,000.00
201673022555London 1£5,000.00
201673133666London 2£2,000.00
201683222555London 1£500.00
201683333666London 2£6,000.00
201773022555London 1£2,000.00
201773133666London 2£3,000.00
201783222555London 1£2,200.00
201783333666London 2£2,500.00

 

I have tried calculated columns with Lookupvalue on multiple criteria but I am getting error "multiple values returned".

 

Help would be much appreciated.

Didn't realise my account wasn't activated and the thread didn't show until now.

Help Smiley Indifferent

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.