cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

Cómo excluir las fechas de fin de semana (es decir, sábado y domingo) de una columna de fecha en la consulta M.

Hola a todos,

Necesita ayuda para excluir fechas de fin de semana de una columna de fecha en power query editor.

Gracias de antemano

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Aquí está la versión simple.

Ver más abajo y adjunto. Básicamente, agregue una columna DayOfWeekName basada en su fecha y filtre desde allí.

let
  start = Number.From(#date(2021, 1, 1)),
  end = Number.From(#date(2021, 12, 31)),
  Source = {start .. end},
  #"Converted to Table" = Table.FromList(
    Source,
    Splitter.SplitByNothing(),
    null,
    null,
    ExtraValues.Error
  ),
  #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table", {{"Column1", type date}}),
  #"Renamed Columns" = Table.RenameColumns(#"Changed Type", {{"Column1", "Date"}}),
  #"Inserted Day Name" = Table.AddColumn(
    #"Renamed Columns",
    "Day Name",
    each Date.DayOfWeekName([Date]),
    type text
  ),
  #"Filtered Rows" = Table.SelectRows(
    #"Inserted Day Name",
    each ([Day Name] <> "Saturday" and [Day Name] <> "Sunday")
  )
in
  #"Filtered Rows"

View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Aquí está la versión simple.

Ver más abajo y adjunto. Básicamente, agregue una columna DayOfWeekName basada en su fecha y filtre desde allí.

let
  start = Number.From(#date(2021, 1, 1)),
  end = Number.From(#date(2021, 12, 31)),
  Source = {start .. end},
  #"Converted to Table" = Table.FromList(
    Source,
    Splitter.SplitByNothing(),
    null,
    null,
    ExtraValues.Error
  ),
  #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table", {{"Column1", type date}}),
  #"Renamed Columns" = Table.RenameColumns(#"Changed Type", {{"Column1", "Date"}}),
  #"Inserted Day Name" = Table.AddColumn(
    #"Renamed Columns",
    "Day Name",
    each Date.DayOfWeekName([Date]),
    type text
  ),
  #"Filtered Rows" = Table.SelectRows(
    #"Inserted Day Name",
    each ([Day Name] <> "Saturday" and [Day Name] <> "Sunday")
  )
in
  #"Filtered Rows"

Syndicate_Admin
Administrator
Administrator

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Users online (849)