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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
trwatts
Helper I
Helper I

Help with calculation

Hey everyone, 

 

I need to work out how many weeks there are in a month but there are some conditions. 
The end goal is to calculate the number of purchases an individual customer makes each week. 

* Need the weeks based on workdays. e.g Mon-Frid is a week. The reason I need to ignore weekends is our sites don't operate on the weekends. Thats important as if a week is between two months say changing on a Wednesday I will need the Monday and Tuesday to calculate to .4 of a week based on five days rather than 0.28 based on 7 days.

* Need to be able to calculate the number of weeks that contain a sale. 

* Need to be able to use that calculation to be filtered by a product type. 

* I would like to only calculate weeks that include a sale. 

Any help would be great.

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @trwatts 

Have you solved this question with VijayP's and amitchandak's help? If you have solved the question, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.

If you need more help, please provide more details,

(1) a sample file, you can replace raw data with bogus data to protect your privacy.

     or provide some sample data that fully covers your issue/question.

(2) give your expected result based on the sample you provide.

Kindly note: Please ensure the data in sample is concise and representative.

Thanks.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

VijayP
Super User
Super User

@trwatts 
Use this file to see whether you are able to get the solution!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


amitchandak
Super User
Super User

@trwatts , You create create a date table

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

WeekDay = WEEKDAY([Date],2)

WeekDay flag = if(WEEKDAY([Date],2) < 6,1,0)

 

then measure like

 

This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank] && 'Date'[WeekDay flag] =1 )))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1 && 'Date'[WeekDay flag] =1 ))

 

4th last week

Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-4 && 'Date'[WeekDay flag] =1 ))

 

Product Type should filter if joined, else we need add code

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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