Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ApurvaKhatri
Helper III
Helper III

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
v-qiuyu-msft
Community Support
Community Support

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.

View solution in original post

5 REPLIES 5
v-qiuyu-msft
Community Support
Community Support

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.
Anonymous
Not applicable

What if it is weeknum 1 and we need weeknum 52?

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.

Greg_Deckler
Super User
Super User

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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Can You please suggest DAx function with proper filter?

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.