The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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
Solved! Go to Solution.
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!
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!