Forum Discussion

Blindreaper's avatar
Blindreaper
New Member
9 years ago

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

  • 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.

    • Blindreaper's avatar
      Blindreaper
      New Member

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

      Help :smileyindifferent:

  • Eric_Zhang's avatar
    Eric_Zhang
    Icon for Microsoft Employee rankMicrosoft 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 )

     

    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
        )

    • Blindreaper's avatar
      Blindreaper
      New Member

      Thank you for your reply Eric_Zhang

       

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