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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to achieve a report based on condition

Hello everyone,

 

I have data somewhat like this as shown below

 

WillTaylorUK_0-1672314777613.png

 

and now I want to extract the data into the one below

 

WillTaylorUK_1-1672314815226.png

Fundamentally I want to get the first Test which is not cleared and denoted as N. I have tried but not able to make that workout, any help will be appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkktLlEwVNJRcgZiQ6VYHaiQEZDrB8RGCCFjqJAxQsgEKmSCEDKFmmUKFgoIgJiro6SAUILDOmdM65wxrUPTaIoiBLHOiCjr/FCFjFHcjeI7Y0zrjJGsM8a0zg+fdRBdJhBdsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Desc = _t, #"C/N" = _t, Quality = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Desc", type text}, {"C/N", type text}, {"Quality", Int64.Type}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [Quality] = null then [#"C/N"] else null),
    #"Filled Up" = Table.FillUp(#"Added Conditional Column",{"Custom"}),
    #"Grouped Rows" = Table.Group(#"Filled Up", {"Custom"}, {{"all", each _, type table [Desc=nullable text, #"C/N"=nullable text, Quality=nullable number, Custom=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom.1", each Table.SelectRows([all], each [#"C/N"]="N")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.2", each Table.First([Custom.1])),
    #"Expanded Custom.2" = Table.ExpandRecordColumn(#"Added Custom1", "Custom.2", {"Desc", "Quality"}, {"Desc", "Quality"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Custom.2",{{"Desc", "First Test Not Cleared"}, {"Custom", "C/N"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"all", "Custom.1"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns",null,"Pass",Replacer.ReplaceValue,{"First Test Not Cleared"}),
    #"Added Custom2" = Table.AddColumn(#"Replaced Value", "Desc", each "PPC"),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom2",{"Desc", "C/N", "First Test Not Cleared", "Quality"})
in
    #"Reordered Columns"

vcgaomsft_0-1672391707070.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkktLlEwVNJRcgZiQ6VYHaiQEZDrB8RGCCFjqJAxQsgEKmSCEDKFmmUKFgoIgJiro6SAUILDOmdM65wxrUPTaIoiBLHOiCjr/FCFjFHcjeI7Y0zrjJGsM8a0zg+fdRBdJhBdsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Desc = _t, #"C/N" = _t, Quality = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Desc", type text}, {"C/N", type text}, {"Quality", Int64.Type}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [Quality] = null then [#"C/N"] else null),
    #"Filled Up" = Table.FillUp(#"Added Conditional Column",{"Custom"}),
    #"Grouped Rows" = Table.Group(#"Filled Up", {"Custom"}, {{"all", each _, type table [Desc=nullable text, #"C/N"=nullable text, Quality=nullable number, Custom=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom.1", each Table.SelectRows([all], each [#"C/N"]="N")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.2", each Table.First([Custom.1])),
    #"Expanded Custom.2" = Table.ExpandRecordColumn(#"Added Custom1", "Custom.2", {"Desc", "Quality"}, {"Desc", "Quality"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Custom.2",{{"Desc", "First Test Not Cleared"}, {"Custom", "C/N"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"all", "Custom.1"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns",null,"Pass",Replacer.ReplaceValue,{"First Test Not Cleared"}),
    #"Added Custom2" = Table.AddColumn(#"Replaced Value", "Desc", each "PPC"),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Custom2",{"Desc", "C/N", "First Test Not Cleared", "Quality"})
in
    #"Reordered Columns"

vcgaomsft_0-1672391707070.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.