Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Need help with YOY line chart

Hello Community!

 

I'm very new to the Power BI and I need your help creating a year over yer comparision line chart.

At the moment I have created a line chart however for the PY it shows full year whereas I only want it to display same yearweek as current.

 

Another thing I need help with is creating a calculation field  'Change' which calculates the difference beween CY sales vs LY sales YTD (LY should only go upto max this years week. ). My data shows weekly and end of last week. I want the YTD total to display CY, and LY should be end of prior week LY(08/13/2022)

 

Below is how somewhat my data displays

Id really appreciate any help. Thank you!

  • Anonymous 

    you can create a scope column, then only do the calculation when scope is y

    pls see the attachment below

13 Replies

  • could you pls paste the sample data (not the screenshot) and also provide the expected output?

  • Anonymous's avatar
    Anonymous
    Not applicable

    ryan_mayu 

    SiteYearWeek EndYearWeekNameAmountCY vs PY
    120225/7/202218AAA500PY
    220235/6/202318BBB100CY
    320225/7/202218CCC300PY
    320225/7/202218EEE350PY
    320225/7/202218AAA100PY
    220235/6/202318BBB500CY
    120225/7/202218BBB750PY
    120235/6/202318AAA600CY
    220225/7/202218AAA150PY
    120235/6/202318EEE35CY
    320225/7/202218AAA95PY
    120225/14/202219EEE160PY
    320235/13/202319AAA285CY
    220225/14/202219EEE125PY
    220235/13/202319EEE150CY
    220225/14/202219CCC200PY
    120235/13/202319EEE450CY
    120225/14/202219CCC365PY
    120225/14/202219AAA250PY
    220235/13/202319BBB950CY
    220225/14/202219BBB1000PY
    320235/6/202318CCC350CY
    220235/13/202319CCC625CY

     

    Heres my sample data. I already have this dashboard on Tableau and I'm trying to recreate it on PowerBI. Below is a snip of what I'm trying to get

    At the moment I have the line chart created however I'm unsure on how to create the red boxed section which displays current year total(YTD), PY total(YTD total as same yearweek as CY), Change in $ and change%.

    • ryan_mayu's avatar
      ryan_mayu
      Super User

      Anonymous 

      here is a wordaround for you

      you just need to change the name filter to create the box for other names.

  • Anonymous's avatar
    Anonymous
    Not applicable

    ryan_mayu  Sorry for the late reply. This is exactly the format I was looking for. I need one additional thing changed and need your help with. My current data is looking YTD and ends last Sat. So for the current report, it should have data from 1/1/23 - 9/2/23. I want the PY to be compare the same time period(Week) so itd be 1/2/22 - 9/3/22 if that makes sense.

    • ryan_mayu's avatar
      ryan_mayu
      Super User

      Anonymous 

      you can create a scope column, then only do the calculation when scope is y

      pls see the attachment below

      • Anonymous's avatar
        Anonymous
        Not applicable

        ryan_mayu Excellent!! This is exactly what I was looking to do. Thanks a lot for all your help!