Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I am pulling several poorly formatted Excel files into PowerBi, these are pulled directly from a a machine so the formatting must remain the same.
The table looks like the below:
| Start Time | End Time | Duration | ||
| 14:00:00 | 15:00:00 | 01:00:00 | ||
| Product | Water | |||
| Amount added | 100 |
I need to create a conditional column for the start and end time of water so I can see it on a gantt chart or similar. Since they are not on the same row, I cannot do this.
I know how to do this via indexes, however since there are around 50 different examples of this, I don't think doing this is feasible. Are there any other methods I could use to achieve the result I want?
Solved! Go to Solution.
Hi @Anonymous , please paste this query in your advanced editor & check if it works according to your requirement.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjSxMjAAIiUdJUNTOFMBig0MoUKxOtFwwYCi/JTS5BIQMzyxJLUILIyswDE3vzSvRCExJSU1BcQ3BJupFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Start Time" = _t, #"End Time" = _t, #" " = _t, #" .1" = _t, Duration = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Start Time", type time}, {"End Time", type time}, {" ", type text}, {" .1", type text}, {"Duration", type time}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#" "]), " ", " .1"),
#"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{" "}),
#"Filled Down" = Table.FillDown(#"Removed Columns",{"Duration"}),
#"Filled Up1" = Table.FillUp(#"Filled Down",{"Duration", "End Time", "Start Time"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Up1", each ([#"Product "] = "Water"))
in
#"Filtered Rows"
Hi @Anonymous , please paste this query in your advanced editor & check if it works according to your requirement.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjSxMjAAIiUdJUNTOFMBig0MoUKxOtFwwYCi/JTS5BIQMzyxJLUILIyswDE3vzSvRCExJSU1BcQ3BJupFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Start Time" = _t, #"End Time" = _t, #" " = _t, #" .1" = _t, Duration = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Start Time", type time}, {"End Time", type time}, {" ", type text}, {" .1", type text}, {"Duration", type time}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[#" "]), " ", " .1"),
#"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{" "}),
#"Filled Down" = Table.FillDown(#"Removed Columns",{"Duration"}),
#"Filled Up1" = Table.FillUp(#"Filled Down",{"Duration", "End Time", "Start Time"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Up1", each ([#"Product "] = "Water"))
in
#"Filtered Rows"
This worked however I have already pivotted the columns earlier so I cannot do it again.
Hi @Anonymous ,
Why can't you pivot the table again?
Can you share more information like Query or Pbix?
Best Regards,
Jay
Thanks for your reply, ideally I would like the end result to look like this:
| Start Time | End Time | Product | Amount Added | Duration |
| 14:00:00 | 15:00:00 | Water | 100 | 01:00:00 |
However if it looked like this ( this is what I was going for with the conditional columns), this would also work.
| Start Time | End Time | Water Start Time | Water End Time | Duration | Water Amount Added |
| 14:00:00 | 15:00:00 | 14:00:00 | 15:00:00 | 1:00:00 | 100 |
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 57 | |
| 33 | |
| 32 | |
| 18 | |
| 16 |
| User | Count |
|---|---|
| 65 | |
| 64 | |
| 44 | |
| 30 | |
| 28 |