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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
akhaliq7
Post Prodigy
Post Prodigy

Turn number of days into weeks using power query

I would like to turn number of days into weeks, my days column is a numeric field. I solved this by dividing the number of days by 7 but wanted to know if there was a function in power query for this task. As functions tend to normally have other data preserving measures such as ignoring nulls

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @akhaliq7,

 

The approach you've taken is correct, there is no standard library function in the M language (at this time) to determine the number of weeks based on a number of elapsed days.

For dealing with null values you can include the coalese operator: ?? (a double questionmark) directly following the field reference that could include nulls and supply it an alternative, to illlustrate:

[Num of Days] / 7                 //if  [Num of Days] = null this will return null

[Num of Days]?? 0 / 7         //if  [Num of Days] = null  then 0 this will return 0

 

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

View solution in original post

1 REPLY 1
m_dekorte
Super User
Super User

Hi @akhaliq7,

 

The approach you've taken is correct, there is no standard library function in the M language (at this time) to determine the number of weeks based on a number of elapsed days.

For dealing with null values you can include the coalese operator: ?? (a double questionmark) directly following the field reference that could include nulls and supply it an alternative, to illlustrate:

[Num of Days] / 7                 //if  [Num of Days] = null this will return null

[Num of Days]?? 0 / 7         //if  [Num of Days] = null  then 0 this will return 0

 

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Kudoed Authors