The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello!
Can anybody help me to transform the columns values (Date Difference) which are not constant into multiple columns as shown below: Its an urgent request from my client who need exact 4 columns as output for all the time frames. Thanks in advance.
Input | output | |||
Date difference | Week(w) | Day(d) | hours(h) | minutes(m) |
1w 5d 18h 54m | 1 | 5 | 18 | 54 |
1d 1h 3m | - | 1 | 1 | 3 |
2h 20m | - | - | 2 | 20 |
10m | - | - | - | 10 |
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMixXME1RMLTIUDA1yVWK1QGKALkZCsYQjlGGgpEBVBxKG5UbZygoKBgZQbiWKUCOoQWQEwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date difference" = _t]),
Split = Table.AddColumn(Source, "Split",
each let
txt = Text.Remove([Date difference], " "),
chars = Text.Select(txt, {"a".."z"})
in
Record.FromList(List.RemoveLastN(Text.SplitAny(txt, chars)), Text.ToList(chars))
),
#"Expanded Split" = Table.ExpandRecordColumn(Split, "Split", {"w", "d", "h", "m"})
in
#"Expanded Split"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi @CNENFRNL ,
Thanks for the quick reply,
As I am new to power BI, Can you please let me the steps to execute your code (or) where to copy your code.
Can i copy your code to custom column ? if so then I am getting values as table, table... in the new column.
PLease guide me. thanks