Forum Discussion

alvaro3432's avatar
alvaro3432
New Member
5 years ago
Solved

Calculate week evoluton

Im having troubles calculting weekly evolution of a variable. In my table i have 2 columns:

 

1) sales

2) weekstart_date (which contains the exact date of the start of the week)

 

I want to plot the evolution of sales between week_start_date and week_start_date - 7, can someone please help me out?

  • Hi, alvaro3432 

    Please correct me if I wrongly understand your question.

     

    I created dim-date-table, and in Powe Query Editor, I added week-start-date-column.

    I marked the dim-date-table as a date-table.

    I connected the main fact table and the date table.

    I used the below measures to create the below picture.

    The sample pbix file's link is down below.

     

     

    Previous Week Sales Total =
    VAR currentweekstartdate =
    MAX ( DatesTable[Start of Week] )
    RETURN
    CALCULATE (
    [Sales Total],
    DatesTable[Start of Week] = currentweekstartdate - 7
    )
     
    Other measures are shown in the pbix file.
     
     

    Hi, My name is Jihwan Kim.

    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

3 Replies

  • Hi, alvaro3432 

    Please correct me if I wrongly understand your question.

     

    I created dim-date-table, and in Powe Query Editor, I added week-start-date-column.

    I marked the dim-date-table as a date-table.

    I connected the main fact table and the date table.

    I used the below measures to create the below picture.

    The sample pbix file's link is down below.

     

     

    Previous Week Sales Total =
    VAR currentweekstartdate =
    MAX ( DatesTable[Start of Week] )
    RETURN
    CALCULATE (
    [Sales Total],
    DatesTable[Start of Week] = currentweekstartdate - 7
    )
     
    Other measures are shown in the pbix file.
     
     

    Hi, My name is Jihwan Kim.

    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

    • alvaro3432's avatar
      alvaro3432
      New Member

      Awesome! This woks just fine, thank you very much!

  • Hi,

    Create a Calendar Table and build a Many to One (with the cross filter direction set to Single) relationship from the Weekstart_date of your Data Table to the Date column of your Calendar Table.  To your visual, drag Date from the Calendar Table.  Write this measure

    Total sales = sum(data[sales])

    Hope this helps.