Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a table of projects that have requirements, and I'm trying to determine if all of the requirements have been met for each project. If any requirement has not been met, the project itself has not met its requirements. Regardless of the amount of requirements, there are columns for three. If a project only has one, then the other two are null and are ignored. I'm finding it difficult to only evaluate the requirements columns that have values.
The data looks like this
project | req_1 | req_1_met | req_2 | req_2_met | req_3 | req_3_met |
project_1 | gleam the cube | TRUE | do the right thing | TRUE | ghosts busted | TRUE |
project_2 | come to america | TRUE | run the blade | TRUE | ||
project_3 | dance flashed | TRUE | groove krushed | FALSE | foot loose | TRUE |
I don't know how to do this without something like a `do while` loop. Also wasn't sure if this should be done in power query.
Thanks!
edit: wow that table is ugly. Should look like this
Hi @genehiggins ,
Thank you for engaging with the Microsoft Fabric Community. @lbendlin response matches your requirement. Please review it when you have a chance and let us know if you need any changes.
Thank you.
What you are looking for is the Unpivot option - usually needed to bring Excel data into a format that is usable by Power BI.
after that it will be easy to achieve your objective in Power BI.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY69DsIwDIRfxcrcBXgCBpiY+JmqCOXHTQppjRKH5yeNgHSwbH0n313fi1ekBxq+b0QnXEA1AXsEkzUWcD3fDmVZqjCOznO5xtk1zXlKnEDnxGh/WHbNeFugoQmBCdSEcTSqfcc8V2sdlF0FQp21y26poWaDMASVfIsqDSLRG+EZ85cf96fLIgxEDIEo/Z2l/AA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [project = _t, req_1 = _t, req_1_met = _t, req_2 = _t, req_2_met = _t, req_3 = _t, req_3_met = _t]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"project"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("_", QuoteStyle.Csv), {"Attribute.1", "req #", "status"}),
#"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter",null,"req",Replacer.ReplaceValue,{"status"}),
#"Removed Columns" = Table.RemoveColumns(#"Replaced Value",{"Attribute.1"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[status]), "status", "Value")
in
#"Pivoted Column"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.
hello @genehiggins
what is the desired outcome from the above sample data?
is it counting of project with TRUE value in all requirements?
Thank you.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
7 |