cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

To fetch previous week data

I have a table viewKPI with column [todate] and [lease seated]

 

I want to calculate sum([lease seated]) for last week from the column [todate].

 

How can I acheive this

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-qiuyu-msft
Moderator

Re: To fetch previous week data

Hi @ApurvaKhatri,

 

You can create a measure below: 

 

LastWeekTotal = CALCULATE(SUM(Table1[lease seated]),FILTER(ALL(Table1),WEEKNUM('Table1'[todate],1)=WEEKNUM(TODAY(),1)-1))

 

q1.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Super User
Super User

Re: To fetch previous week data

Oddly, there is no PREVIOUSWEEK function. You would need to use a CALCULATE with an appropriate FILTER. I would use something like DATEADD with a -7 days in your filter. Again, oddly, the DATEADD function does not support weeks.


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


Re: To fetch previous week data

Can You please suggest DAx function with proper filter?

 

Moderator v-qiuyu-msft
Moderator

Re: To fetch previous week data

Hi @ApurvaKhatri,

 

You can create a measure below: 

 

LastWeekTotal = CALCULATE(SUM(Table1[lease seated]),FILTER(ALL(Table1),WEEKNUM('Table1'[todate],1)=WEEKNUM(TODAY(),1)-1))

 

q1.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Re: To fetch previous week data

Hi.. Thanks for the reply.

 

Can you explain the signigicance of -1 in the formule.

 

Actually, I am trying to hardcode values of previous 12 weeks data starting from today and going back 12 weeks fo every column.

 

e.g:

 

                            16thoct   9thoct   2ndoct  25thsept ..... till 12 weeks

Total Salary          ....              ....         ....

 

 

Thanks,

Apurva Khatri.