julianazanelatto / power_bi_analyst

353 stars 1.22k forks source link

DESAFIO 5 #32

Open AGUSDEL123 opened 10 months ago

AGUSDEL123 commented 10 months ago

Screenshot_27

Segue modelo, calendário

let DataMin = List.Min(financials_origem [Date]), // mudar as tabelas e coluna DataMax = List.Max(financials_origem [Date]), // mudar as tabelas e coluna

Dias = Duration.Days(DataMax - DataMin) + 1,
Datas = List.Dates(DataMin, Dias, #duration(1, 0, 0, 0)),
ListaparaTabela = Table.FromList(Datas, Splitter.SplitByNothing(), {"Data"}, null, ExtraValues.Error),
AlterarTipo = Table.TransformColumnTypes(ListaparaTabela, {{"Data", type date}}),
Ano = Table.AddColumn(AlterarTipo, "Ano", each Date.Year([Data]), Int64.Type),
Trimestre = Table.AddColumn(Ano, "Trimestre", each "Trim " & Number.ToText(Date.QuarterOfYear([Data])), type text),
NumeroSemana = Table.AddColumn(Trimestre, "Número Semana", each Date.WeekOfYear([Data]), Int64.Type),
MesNumero = Table.AddColumn(NumeroSemana, "Número Mês", each Date.Month([Data]), Int64.Type),
DataINT = Table.AddColumn(MesNumero, "DateInt", each [Ano] * 100 + [Número Mês], Int64.Type),
NomeMes = Table.AddColumn(DataINT, "Mês", each Date.ToText([Data], "MMM"), type text),
MesMaiusculo = Table.TransformColumns(NomeMes, {{"Mês", Text.Proper, type text}}),
DiaDaSemana = Table.AddColumn(MesMaiusculo, "Dia da Semana", each Date.ToText([Data], "dddd"), type text),
MesAno = Table.AddColumn(DiaDaSemana, "Mês Ano", each Text.Combine({Text.From([Número Mês], "pt-BR"), Text.From([Ano], "pt-BR")}, "-"), type text)

in MesAno