Forum Discussion

ApurvaKhatri's avatar
ApurvaKhatri
Helper III
8 years ago

Get week from Date

Hello,

 

How can i get weeek dates from a date column

 

E.g 

 

I have a column Spend and a Date column with continous dates (my spend amount is calculated on daily basis)

 

I need to calculate sum(spend) on weekly basis based on date column.

 

2017 - 10- 24      405

2017 -10- 23        200

2017-10-22    150

2017-10-21    100

2017-10-20     100

2017-10-19      125

2017-10-18     250

2017-10-17    150

2017-10-16   100

2017-10-15   50 

2017-10-14  500

2017-10-13  600

 

I need the sum for every week e.g 2017-10-14 to 2017-10-20  sum(spend)

How do i get week from dates and then calculate sum(spend)

 

I have data from 2016 Jan to date.

 

 

 

 

5 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    You can use WEEKNUM function in DAX in a calculated column to return the week of the year.

    • ApurvaKhatri's avatar
      ApurvaKhatri
      Helper III

      We need the dates like start and end date of the week to be displayed 

    • MarcelBeug's avatar
      MarcelBeug
      Community Champion

      You also need to know if you are using ISO week numbers (Monday through Sunday), in which ALL weeks are complete weeks, or the default week numbering where January 1 is always week 1 and a new week starts on Sunday (e.g. Saturday Jan 1 is week 1 and Sunday Jan 2 is already week 2, which would still be ISO week 52 or 53).

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi ApurvaKhatri,

     

    You said the dates are continuous. I am not going to create a new date table. 

    1. Create a new Calculated Column "WeekNum".

    WeekNum = WEEKNUM([Date] + 1,1)

    2. Two measures.

    StartOfWeek = min('Table1'[Date])
    EndOfWeek = max('Table1'[Date])

    3. Create a report. 

    [Year]  [Weeknum]  [StartOfWeek]  [EndOfWeek] [Spend] (sum)

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Best Regards!

    Dale

     

  • Santamaria5's avatar
    Santamaria5
    Regular Visitor

    Hola! 

    Necesito presentar una grafica bisemanalmente del un año, no encuentro la manera de como realizarlo si hay alguna funcion que me ayude a que me agrupe los datos bisemanalmente

     

    de esta manera