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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

Crear una columna de fecha basada en la condición de la columna

@amitchandak ,

Quiero crear una tabla de campos de fecha como resultado basada en varias condiciones.

Se trata de datos que contienen scheduled_tasks ejecuciones.

Datos que tengo:

Tarea Fecha de inicioRepita porRepita cada
Tarea 101-12-23Días1
Tarea 201-12-23Días2

basado en la repetición por y repetir cada , he creado una salida de fecha,

Condición:
La fecha de inicio de la tarea 1 es 01-12-23 y se ejecuta diariamente, por lo que la salida debe ser hasta la fecha de la tarea 1.
La fecha de inicio de la tarea 2 es 01-12-23, se ejecuta dos días una vez, por lo que la salida debe ser fechas alternativas para la tarea 2.

Resultado esperado
TareaFecha
Tarea101-12-23
Tarea 201-12-23
Tarea102-12-23
Tarea103-12-23
Tarea 203-12-23
Tarea104-12-23
Tarea105-12-23
Tarea 205-12-23

El resultado de la salida debería llegar hasta hoy. Si al día siguiente llega el basado en una condición, tenemos que mostrar qué tarea se ejecutará ese día.

Necesidad de crear una tabla hasta la fecha

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

@Navaneetharaju_ ,

No estoy seguro de cuándo desea tener la fecha de finalización para esto, pero intente lo siguiente:

  • Agregue una columna personalizada con una lista de 1..100
 {1..100}
  • Ampliar la lista
  • Agregue la siguiente columna
Number.Mod ([Custom]/[repeat every] ,1) = 0 
  • Filtrar para mostrar solo los valores TRUE

Complete el código a continuación:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkkszlYwVNJRUjAw1DU00jUyBrFTEiuLQbShUqwOVI0RLjVGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Task " = _t, #"Start date" = _t, #"repeat by" = _t, #"repeat every" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Task ", type text}, {"Start date", type date}, {"repeat by", type text}, {"repeat every", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {1..100}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", Int64.Type}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type1", "Custom.1", each  Number.Mod ([Custom]/[repeat every] ,1) = 0 ),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom1", each ([Custom.1] = true))
in
    #"Filtered Rows"

@MFelix ,

La última fecha debe ser una fecha today(). (19-dic-2023).

Si estoy mirando el informe de mañana, ese día debería ser una última fecha.

@Navaneetharaju_ ,

Simplemente cambie la fórmula de la lista por esta:

{0.. Number.From( Date.From (DateTime.LocalNow())- [Start date])}

Todo el resto del código es el mismo.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkkszlYwVNJRUjAw1DU00jUyBrFTEiuLQbShUqwOVI0RLjVGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Task " = _t, #"Start date" = _t, #"repeat by" = _t, #"repeat every" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Task ", type text}, {"Start date", type date}, {"repeat by", type text}, {"repeat every", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each  {0.. Number.From( Date.From (DateTime.LocalNow())- [Start date])}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", Int64.Type}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type1", "Custom.1", each  Number.Mod ([Custom]/[repeat every] ,1) = 0 ),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom1", each ([Custom.1] = true)),
    #"Added Custom2" = Table.AddColumn(#"Filtered Rows", "FInal Date", each [Start date] + #duration([Custom] ,0 , 0 , 0))
in
    #"Added Custom2"

@MFelix ,

La última fecha debe ser la fecha de hoy.

Recibo este error

Navaneetharaju__0-1702984823417.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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