Forum Discussion

Tine82's avatar
Tine82
Icon for Helper I rankHelper I
2 months ago
Solved

Help Needed: Displaying Previous and Next Week in Power BI Table Visual

Hello PBI Community,

I'm currently facing a challenge in Power BI and would greatly appreciate your support as I'm a bit stuck.

I have a Table Visual with the following data:

  • Product
  • Material No
  • Week
  • Order Qty

My goal is to add columns to this table that display the "Order Qty" for the previous week and the next week.

Here's an example of how it should look (see picture)

 



  • Hi Tine82 ,

     

    Thanks you for reaching out to fabric community.

     

    Thanks pankajnamekar25  and jgeddes  for the prompt response.

     

    Could you please check the provided solution and let us know if you have any further questions.

     

    Thanks!!

3 Replies

  • Something like these might work for you...

    Measure (Previous Week) = 
    CALCULATE(
        SUM('Table'[Order Qty]),
        FILTER(ALLEXCEPT('Table', 'Table'[Product], 'Table'[Material No]), 'Table'[Week] = SELECTEDVALUE('Table'[Week]) - 1)
    )

     

    Measure (Next Week) = 
    CALCULATE(
        SUM('Table'[Order Qty]),
        FILTER(ALLEXCEPT('Table', 'Table'[Product], 'Table'[Material No]), 'Table'[Week] = SELECTEDVALUE('Table'[Week]) + 1)
    )

     

     

  • Hello Tine82 

     

    Add two measures using CALCULATE + ALL to pivot to the adjacent week, then put them next to Order Qty in your table.

    Prev Week Order Qty =
    VAR CurrentWeek = SELECTEDVALUE('WeekTable'[Week Number])
    RETURN
    CALCULATE(
    SUM('FactTable'[Order Qty]),
    ALL('WeekTable'),
    'WeekTable'[Week Number] = CurrentWeek - 1
    )


    Next Week Order Qty =
    VAR CurrentWeek = SELECTEDVALUE('WeekTable'[Week Number])
    RETURN
    CALCULATE(
    SUM('FactTable'[Order Qty]),
    ALL('WeekTable'),
    'WeekTable'[Week Number] = CurrentWeek + 1
    )
    Drop both into the table alongside your existing Order Qty column. Product/Material filter stays intact automatically; only the week filter gets overridden.

     


    If my response helped you, please consider clicking
    Accept as Solution and giving it a Like 👍 – it helps others in the community too.

    Thanks,

    Connect with me on:
    LinkedIn |
    Data With Pankaj - YouTube
  • v-sathmakuri's avatar
    v-sathmakuri
    Icon for Community Support rankCommunity Support

    Hi Tine82 ,

     

    Thanks you for reaching out to fabric community.

     

    Thanks pankajnamekar25  and jgeddes  for the prompt response.

     

    Could you please check the provided solution and let us know if you have any further questions.

     

    Thanks!!