Forum Discussion

SCNCKS1's avatar
SCNCKS1
Helper I
3 years ago
Solved

converting dax to M

Hi - I found the code below that will create perpetual holiday for my date calendar in dax, I would like to create the same thing in M (Power query), is this possible?

 

   -- New Year's Day (including weekend observations)
        //// When falling on Saturday, move to preceding Friday
        MONTH([Date]) = 12 && DAY([Date]) = 31 && WEEKDAY([Date], 1 ) = 6, "New Year's Day (Observed)",
        //// When falling on Sunday, move to following Monday
        MONTH([Date]) = 1 && DAY([Date]) = 2 && WEEKDAY( [Date], 1 ) = 2, "New Year's Day (Observed)",
        //// When falling on normal workday, do not shift holiday observation
        MONTH([Date]) = 1 && DAY([Date]) = 1 && WEEKDAY([Date], 1 ) IN { 2, 3, 4, 5, 6 }, "New Year's Day",
  • pls try this

     

    if Date.Month([Date]) = 12 and Date.Day([Date]) = 31 and Date.DayOfWeek([Date], 1 ) = 6  then  "New Year's Day (Observed)" else if 
            Date.Month([Date]) = 1 and Date.Day([Date]) = 2 and Date.DayOfWeek( [Date], 1 ) = 2 then  "New Year's Day (Observed)" else if
      
    Date.Month([Date]) = 1 and Date.Day([Date]) = 1 and List.ContainsAny({ Text.From(Date.DayOfWeek([Date], 1 ))} , { "2".."6" })= true then "New Year's Day" else ""

1 Reply

  • pls try this

     

    if Date.Month([Date]) = 12 and Date.Day([Date]) = 31 and Date.DayOfWeek([Date], 1 ) = 6  then  "New Year's Day (Observed)" else if 
            Date.Month([Date]) = 1 and Date.Day([Date]) = 2 and Date.DayOfWeek( [Date], 1 ) = 2 then  "New Year's Day (Observed)" else if
      
    Date.Month([Date]) = 1 and Date.Day([Date]) = 1 and List.ContainsAny({ Text.From(Date.DayOfWeek([Date], 1 ))} , { "2".."6" })= true then "New Year's Day" else ""