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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jackj
Helper I
Helper I

Convert a Formula from looking at months to looking at weeks

I am using the following formula for a calculated column, which works perfectly, to determine if a userID visited in the previous month, and adds a " 1" to the row to signify that that userID visited one month ago.  I am looking to replicate the same thing, except I want to determine if that userID visited one WEEK ago instead.  Below is the formula that works:

 

Active Last Month = IF(
CALCULATE(
COUNTROWS('warehouse Orders'),
PREVIOUSMONTH('warehouse Orders'[Visit Month]),
ALLEXCEPT('warehouse Orders','warehouse Orders'[UserID])
)
>0,1,0)
 
[Visit Month] is a calculated column taking the actual order date and putting it in a Month context.  I have a similar column, [Visit Week] which takes the actual order date and converts it to the end of the week.  I am looking to determine if the user visited in the week prior.
 
Basically, I want to replace the PREVIOUSMONTH('warehouse Orders'[Visit Month]) with a line that does the exact same thing, but looks for the previous week instead.  Any ideas?
1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @jackj 

Try this

 

 

Active Last Week = IF(
CALCULATE(
COUNTROWS('warehouse Orders'),
FILTER('warehouse Orders', WEEKNUM('warehouse Orders'[Order Date]) = WEEKNUM('warehouse Orders'[Visit Week]) - 1),
ALLEXCEPT('warehouse Orders','warehouse Orders'[UserID])
)
>0,1,0)

 

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.