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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Julia2023
Helper I
Helper I

Count the number of weeks

Hi, can you help count the number of weeks in the selected month? Instead of using the hardcoded value '4', it should calculate the number of weeks in the selected month.

Measure:

Budget = 'Budget'[Budget $ SUM]/4

 

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from@lbendlin ,please allow me to provide another insight:

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1719538572288.png

2.Create calculated column references:

weeknumber = WEEKNUM('Table'[Date])

3. Below are the measure I've created for your needs:

Budget = 
VAR number1=DISTINCTCOUNT('Table'[weeknumber])
RETURN 'Table'[Budget $ SUM]/number1

4.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1719538633557.png

vlinyulumsft_2-1719538641361.png

 

 

5.Here is the relevant documentation:

WEEKNUM function (DAX) - DAX | Microsoft Learn

 

Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

2 REPLIES 2
Anonymous
Not applicable

Thanks for the reply from@lbendlin ,please allow me to provide another insight:

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1719538572288.png

2.Create calculated column references:

weeknumber = WEEKNUM('Table'[Date])

3. Below are the measure I've created for your needs:

Budget = 
VAR number1=DISTINCTCOUNT('Table'[weeknumber])
RETURN 'Table'[Budget $ SUM]/number1

4.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1719538633557.png

vlinyulumsft_2-1719538641361.png

 

 

5.Here is the relevant documentation:

WEEKNUM function (DAX) - DAX | Microsoft Learn

 

Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

lbendlin
Super User
Super User

What is your definition of week?  Do you want to see an integer number or a decimal number (4.428571428571 weeks, for example) ?

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.