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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Super User
Super User

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!:
Power BI Cookbook Third Edition (Color)

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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