Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

VLOOKUP Report Stock Evolution POWER BI

Dear, 

 

I have to report the evolution of stock between two identical files that changes from one week to another.

 

To do this, I perform a VLOOKUP in Excel from the last file obtained 'Claims - Current Week' which is larger than the file 'Claims - Previous week' from the previous week.

 

I therefore compare the extraction of the previous week with that of the current week from a key named "CLAIM ID".

At the end of this, I filter on the result of my search column V in 'Claims - Current Week' on the N/A field. Only the N/A fields have to be reported.

 

That's why I would like to reproduce this VLOOKUP in PowerBi to be able to automate it.

 

Could you please help me with this. 

 

Thank you.

 

 

5 Replies

  • v-alq-msft's avatar
    v-alq-msft
    Community Support

    Hi, Anonymous 

     

    I assume that you want to compare 'Claims-Current Week' with 'Claims-Last Week' for specific 'Claim ID'. I created data to reproduce your scenario. The pbix file is attached in the end.

     

    Table:

     

    Calendar(a calculated table):

    Calendar = CALENDARAUTO()

     

    There is a relationship between two tables. You may create calculated columns and measures as below.

    Calculated Column:
    YearWeek = YEAR('Calendar'[Date])*100+WEEKNUM('Calendar'[Date])

     

    Measure:
    Claims-Current Week = 
    var _currentweek = YEAR(TODAY())*100+WEEKNUM(TODAY())
    var tab = 
    SUMMARIZE(
        'Table',
        'Table'[Claim ID],
        "CurrnetWeek",
        var _claimid = [Claim ID]
        return
        CALCULATE(
            SUM('Table'[Value]),
            FILTER(
                ALL('Table'),
                'Table'[Claim ID] = _claimid&&
                RELATED('Calendar'[YearWeek]) = _currentweek
            )
        )
    )
    
    return
    SUMX(
        tab,
        [CurrnetWeek]
    )
    
    Claims-Last Week = 
    var _currentweek = YEAR(TODAY())*100+WEEKNUM(TODAY())
    var tab = 
    SUMMARIZE(
        'Table',
        'Table'[Claim ID],
        "LastWeek",
        var _claimid = [Claim ID]
        return
        CALCULATE(
            SUM('Table'[Value]),
            FILTER(
                ALL('Table'),
                'Table'[Claim ID] = _claimid&&
                RELATED('Calendar'[YearWeek]) = 
                CALCULATE(
                    MAX('Calendar'[YearWeek]),
                    FILTER(
                        ALL('Calendar'),
                        'Calendar'[YearWeek]<_currentweek
                    )
                )
            )
        )
    )
    return
    SUMX(
        tab,
        [LastWeek]
    )

     

    Result:

     

    If i misunderstand your thoughts, please show us some sample data and  expected result with OneDrive for business. Do mask sensitive data before uploading. Thanks.

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • v-alq-msft's avatar
    v-alq-msft
    Community Support

    Hi, Anonymous 

     

    If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

     

    Best Regards

    Allan