Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Olá!
Desculpem, não sei como clarificar o tema no assunto, mas basicamente tenho uma tabela que possui duas colunas:
- Uma coluna de Data de criação do processo.
- Outra coluna de data de "fim" do processo.
Porém, eu preciso que cada dia entre a data início e data fim sejam transformados em linhas.
Abaixo um print do modelo atual:
Coluna da esquerda é a data de criação, e a coluna da direita é a data de fim.
Ou seja, se o processo abriu no dia 16/01/2023 e fechou no dia 19/01/2023, eu teria 4 linhas para este processo (16/01, 17/01, 18/01 e 19/01).
No caso da data fim estar vazia, queria que existisse uma linha para cada dia que passou entre o início do processo até hoje, já que o processo ainda não foi fechado.
O resultado final ficaria assim:
As linhas se mantém, e existiria uma coluna com a data de controle.
Se houver uma solução para isso, ou se precisarem de mais detalhes, fico à disposição.
Muito obrigado!
Solved! Go to Solution.
Boa tarde @marcelocostafil ,
Deves adicionar uma nova coluna calculada com o seguinte código:
try { Number.From (Date.From ([Data])) ..
Number.From(Date.From ([DataSaid]))}
otherwise
{ Number.From (Date.From ([Data])) ..
Number.From(Date.From (DateTime.LocalNow()))}
Depois expandes a coluna e formatas com data:
Atenção que no caso de a coluna Data ser maior que o dia de hoje o código dá nulo:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTTNzDUNzIwMlYwNLQyMrQyNFPSUXJ29PMEUYl5mYeXJ+YAma4hrkDSycWnOCUxLa04JS0FyDUEYQuEASZWJhZWpuYgUUuEqKmVibmViYFSrE60ElDQwBwkbkKMdWkpxRC7ivFaBjHZjCYmxwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data = _t, CodPorto = _t, CodPortoDesc = _t, Carregador = _t, Referencia = _t, Confirmado = _t, #"Data confi" = _t, DataSaid = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Data", type datetime}, {"CodPorto", type text}, {"CodPortoDesc", type text}, {"Carregador", type text}, {"Referencia", type text}, {"Confirmado", Int64.Type}, {"Data confi", type datetime}, {"DataSaid", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each try { Number.From (Date.From ([Data])) ..
Number.From(Date.From ([DataSaid]))}
otherwise
{ Number.From (Date.From ([Data])) ..
Number.From(Date.From (DateTime.LocalNow()))}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}})
in
#"Changed Type1"
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsBoa tarde @marcelocostafil ,
Deves adicionar uma nova coluna calculada com o seguinte código:
try { Number.From (Date.From ([Data])) ..
Number.From(Date.From ([DataSaid]))}
otherwise
{ Number.From (Date.From ([Data])) ..
Number.From(Date.From (DateTime.LocalNow()))}
Depois expandes a coluna e formatas com data:
Atenção que no caso de a coluna Data ser maior que o dia de hoje o código dá nulo:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTTNzDUNzIwMlYwNLQyMrQyNFPSUXJ29PMEUYl5mYeXJ+YAma4hrkDSycWnOCUxLa04JS0FyDUEYQuEASZWJhZWpuYgUUuEqKmVibmViYFSrE60ElDQwBwkbkKMdWkpxRC7ivFaBjHZjCYmxwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data = _t, CodPorto = _t, CodPortoDesc = _t, Carregador = _t, Referencia = _t, Confirmado = _t, #"Data confi" = _t, DataSaid = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Data", type datetime}, {"CodPorto", type text}, {"CodPortoDesc", type text}, {"Carregador", type text}, {"Referencia", type text}, {"Confirmado", Int64.Type}, {"Data confi", type datetime}, {"DataSaid", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each try { Number.From (Date.From ([Data])) ..
Number.From(Date.From ([DataSaid]))}
otherwise
{ Number.From (Date.From ([Data])) ..
Number.From(Date.From (DateTime.LocalNow()))}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}})
in
#"Changed Type1"
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThis is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
79 | |
59 | |
36 | |
33 |
User | Count |
---|---|
92 | |
59 | |
59 | |
49 | |
41 |