Forum Discussion

Philip0123's avatar
Philip0123
Frequent Visitor
7 years ago
Solved

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)

 

 

  • 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)
    )

3 Replies