Ir para conteúdo
  • 0

Criar novas linhas a partir de uma coluna de data


Lucas Montezano
Ir para solução Solucionado por Bruno Abdalla de Souza ,

Pergunta

  • Membros

Tenho na minha base(imagem 1) a data inicial e a data final, porém gostaria de ter 12 linhas uma para cada mês para o volume indicado na primeira coluna, como na (imagem 2)

Poderiam me ajudar?

image.png.1637c5d417fa933fa2ba66bd5bb27e57.png

Energy Volume (MWavg) Power Supply Start Date Power Supply Start Date
36500 01/01/2021 31/12/2021
36500 01/02/2021 31/12/2021
36500 01/03/2021 31/12/2021
36500 01/04/2021 31/12/2021
36500 01/05/2021 31/12/2021
36500 01/06/2021 31/12/2021
36500 01/07/2021 31/12/2021
36500 01/08/2021 31/12/2021
36500 01/09/2021 31/12/2021
36500 01/10/2021 31/12/2021
36500 01/11/2021 31/12/2021
36500 01/12/2021 31/12/2021

 

 

 

image.png

image.png

image.png

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 1
  • Membros

Veja se é isso:

let
    Fonte = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjYzNTBQ0lEyMNQHIiMDI0Mgx9hQ39AIwomNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Energy Volume (MWavg)" = _t, #"Power Supply Start Date" = _t, #"Power Supply End Date" = _t]),
    AlteraTipoDados = Table.TransformColumnTypes(Fonte,{{"Energy Volume (MWavg)", Int64.Type}, {"Power Supply Start Date", type date}, {"Power Supply End Date", type date}}),
    CriaListaDatasInicioMes = 
        Table.AddColumn(AlteraTipoDados, "PowerSupplyStartDate", 
            each 
                let
                    pDataIni = [Power Supply Start Date],
                    pDataFim = [Power Supply End Date]
                in
                    List.Transform(
                        {0..((Date.Year(pDataFim)-Date.Year(pDataIni))*12 + Date.Month(pDataFim) - Date.Month(pDataIni))}, 
                        each 
                            Date.AddMonths(pDataIni, _)
                    )
        ),
    RemoveColunaDataInicio = Table.RemoveColumns(CriaListaDatasInicioMes,{"Power Supply Start Date"}),
    ExpandeDataInicio = Table.ExpandListColumn(RemoveColunaDataInicio, "PowerSupplyStartDate"),
    AlteraTipoParaData = Table.TransformColumnTypes(ExpandeDataInicio,{{"PowerSupplyStartDate", type date}})
in
    AlteraTipoParaData

 

ListaDataInicioMes.pbix

Link para o comentário
Compartilhar em outros sites

  • 0
  • Membros

Boa noite @Bruno Abdalla de Souza , me desculpa eu acabei esquecendo de passar uma informação importante na transformação.

Por exemplo se a data inicial for "01/02/2022" e a data final for "31/12/2022" preciso dividir o volume por 11, sempre dividindo o volume pela diferença dos meses, vou mandar um exemplo da base e como eu gostaria que ficasse.

Atual:

Synced Quote Energy Volume (MWavg) Power Supply Start Date Power Supply End Date
RST - FORM - 2022/2023 15000 1/2/2022 31/12/2022
RST - FORM - 2022/2023 15000 1/2/2023 31/12/2023
REC - Gol - 2022/2024 12,82 1/1/2022 31/12/2022
REC - Gol - 2022/2024 13,93 1/1/2023 31/12/2023
REC - Gol - 2022/2024 14,46 1/1/2024

31/12/2024

 

Desejado:

 

Synced Quote Energy Volume (MWavg) Power Supply Start Date Power Supply End Date
RST - FORM - 2022/2023 1363,64 01/02/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/03/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/04/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/05/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/06/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/07/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/08/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/09/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/10/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/11/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/12/2022 31/12/2022
RST - FORM - 2022/2023 1363,64 01/02/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/03/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/04/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/05/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/06/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/07/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/08/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/09/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/10/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/11/2023 31/12/2023
RST - FORM - 2022/2023 1363,64 01/12/2023 31/12/2023
REC - Gol - 2022/2024 1,07 01/01/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/02/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/03/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/04/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/05/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/06/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/07/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/08/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/09/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/10/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/11/2022 31/12/2022
REC - Gol - 2022/2024 1,07 01/12/2022 31/12/2022
REC - Gol - 2022/2024 1,16 01/01/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/02/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/03/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/04/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/05/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/06/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/07/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/08/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/09/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/10/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/11/2023 31/12/2023
REC - Gol - 2022/2024 1,16 01/12/2023 31/12/2023
REC - Gol - 2022/2024 1,21 01/01/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/02/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/03/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/04/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/05/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/06/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/07/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/08/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/09/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/10/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/11/2024 31/12/2024
REC - Gol - 2022/2024 1,21 01/12/2024 31/12/2024

 

Conseguiria me ajudar?

Agradeço desde ja!

 

 

transformação BI.xlsx

Link para o comentário
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisar ser um membro para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar Agora
×
×
  • Criar Novo...