Forum Discussion
Anonymous
6 years agoNot applicable
Writing Rows in a Calculated Table From Flat Data, and Building a Line Graph with the Results
Hi, I'm new to writing dax in Power BI, and I have a need to convert hard data that looks like this into a monthly line graph going out from the task finish date to the number of months in the sa...
- 6 years ago
Anonymous -
See if this gets you close to what you're going for:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc3RDcAgCATQXfi2wUNRO4tx/zUKJhZ/zOUeyJwESlQZypLxWtac7YXQSpPEC8axIl6MTcWnLrrXqsUeJnKjesxcj6JJYLPYuPwme3FT9yvxaUPQ8CNBj8IbGK4P", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ProjectID = _t, FinishDate = _t, Savings = _t, SavingsDuration = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ProjectID", Int64.Type}, {"FinishDate", type date}, {"Savings", Int64.Type}, {"SavingsDuration", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "AssignPeriods", each {1..[SavingsDuration]}), #"Expanded AssignPeriods" = Table.ExpandListColumn(#"Added Custom", "AssignPeriods"), #"Added Custom1" = Table.AddColumn(#"Expanded AssignPeriods", "Monthly Savings", each [Savings] / [SavingsDuration]), #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom", each if [AssignPeriods] = 1 then [FinishDate] else Date.AddMonths([FinishDate],[AssignPeriods] - 1)) in #"Added Custom2"Throw it into the Advanced Editor of a Blank Query.
ChrisMendoza
6 years agoResident Rockstar
Anonymous -
See if this gets you close to what you're going for:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc3RDcAgCATQXfi2wUNRO4tx/zUKJhZ/zOUeyJwESlQZypLxWtac7YXQSpPEC8axIl6MTcWnLrrXqsUeJnKjesxcj6JJYLPYuPwme3FT9yvxaUPQ8CNBj8IbGK4P", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ProjectID = _t, FinishDate = _t, Savings = _t, SavingsDuration = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ProjectID", Int64.Type}, {"FinishDate", type date}, {"Savings", Int64.Type}, {"SavingsDuration", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "AssignPeriods", each {1..[SavingsDuration]}),
#"Expanded AssignPeriods" = Table.ExpandListColumn(#"Added Custom", "AssignPeriods"),
#"Added Custom1" = Table.AddColumn(#"Expanded AssignPeriods", "Monthly Savings", each [Savings] / [SavingsDuration]),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom", each if [AssignPeriods] = 1 then [FinishDate] else Date.AddMonths([FinishDate],[AssignPeriods] - 1))
in
#"Added Custom2"Throw it into the Advanced Editor of a Blank Query.
- Anonymous6 years agoNot applicable
This is exactly what I was trying to do - thank you so much :)