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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Milestones forecast/actual from columns to rows

Hi!

 

I received an excel file organized similar to this one (fake dataset):

 

IndexM1 ForecastM1 ActualM2 ForecastM2 ActualM1 SuccessM2 Success
101/01/201005/01/201003/02/201003/02/2010FALSETRUE
217/01/201017/01/201009/02/201010/02/2010TRUEFALSE
322/01/201023/01/201015/02/201015/02/2010FALSETRUE
425/01/201026/01/201026/02/201028/02/2010FALSEFALSE

 

Where M is for Milestone (and of course the columns and the rows are really in the hundreds).

I basically compare the "Forecast" and the "Actual" dates to evaluate if the Milestone was completed on time.

 

I would like to:

 

1. Have a list of Milestones that I can use as a filter.

 

2. Automate the creation of the "Success" column, to avoid the copy/paste/edit repetitive task for each milestone.

 

My idea (pseudocode badly mixing Java and M):

- create an array of array:     arr = {{M1F,M1A}, {M2F,M2A}}

- loop through it:  for(i = 0; i<arr.lenght; i++) { Table.AddColumn(MyTable, Milestones[i], each if arr[i][1]< arr[i][0] then true else false )} 

 

Where Milestones[i] is the String value name of the Milestone, from the Milestones list.

 

Any idea how to do this in Power Query or DAX?

 

Thanks

 

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

If you looking for this as an outcome.

image.png

Then you can use the M script below.

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bY7LDcAwCEN34Rwp4JR+ZkHZf42SS2uqSlye5WcRISZN1Hoe1HSBM4yu+IHZQpCRHVQuoBeZpsUcGQFUxuAZZ9OLua0yP4j9A4+J8zXnDQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Index = _t, #"M1 Forecast" = _t, #"M1 Actual" = _t, #"M2 Forecast" = _t, #"M2 Actual" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Index"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Milestone", "Attribute.2"}),
    #"Pivoted Column" = Table.Pivot(#"Split Column by Delimiter", List.Distinct(#"Split Column by Delimiter"[Attribute.2]), "Attribute.2", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"Index", Int64.Type}, {"Forecast", type date}, {"Actual", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Success", each [Forecast]=[Actual], type logical )
in
    #"Added Custom"

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

 

 

View solution in original post

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

If you looking for this as an outcome.

image.png

Then you can use the M script below.

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bY7LDcAwCEN34Rwp4JR+ZkHZf42SS2uqSlye5WcRISZN1Hoe1HSBM4yu+IHZQpCRHVQuoBeZpsUcGQFUxuAZZ9OLua0yP4j9A4+J8zXnDQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Index = _t, #"M1 Forecast" = _t, #"M1 Actual" = _t, #"M2 Forecast" = _t, #"M2 Actual" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Index"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Milestone", "Attribute.2"}),
    #"Pivoted Column" = Table.Pivot(#"Split Column by Delimiter", List.Distinct(#"Split Column by Delimiter"[Attribute.2]), "Attribute.2", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Pivoted Column",{{"Index", Int64.Type}, {"Forecast", type date}, {"Actual", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Success", each [Forecast]=[Actual], type logical )
in
    #"Added Custom"

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

 

 

Anonymous
Not applicable

That's great, Thanks Mariusz!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors