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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Philip0123
Frequent Visitor

Power query M function simlar to DAX SWITCH()

Hi,

 

I'm not that familiar with the M language, but I've got a formula (see below) with output = 1 to 7 representing the day of the week. I need to replace the number with the day name.  Tried the Repacer.ReplaceValue() function, but it only allows me to replace one value, maybe I'm not being inventive enough and need to incorporate list functions or something?

 

Formula (used to define the day as 6-6 instead of 12-12 as per the standard formulas):

 

Date.DayOfWeek(
[Malfunct. start]
+ #duration(0,Time.Hour([#"Start Malfn (T)"]),Time.Minute([#"Start Malfn (T)"]),Time.Second([#"Start Malfn (T)"]))
- #duration(0,6,0,0)
,0)

 

 

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

will Date.DayOfWeekName do the job? As below:

Date.DayOfWeekName(
[Malfunct. start] 
+ #duration(0,Time.Hour([#"Start Malfn (T)"]),Time.Minute([#"Start Malfn (T)"]),Time.Second([#"Start Malfn (T)"]))
- #duration(0,6,0,0)
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

3 REPLIES 3
Stachu
Community Champion
Community Champion

will Date.DayOfWeekName do the job? As below:

Date.DayOfWeekName(
[Malfunct. start] 
+ #duration(0,Time.Hour([#"Start Malfn (T)"]),Time.Minute([#"Start Malfn (T)"]),Time.Second([#"Start Malfn (T)"]))
- #duration(0,6,0,0)
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Greg_Deckler
Community Champion
Community Champion

I'm sure @ImkeF has the answer.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.