Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi I have the following issue:
I have a table as below
id | source_id | |
100 | ||
101 | 100 | |
102 | ||
103 | 102 | |
104 | 101 | |
105 | 104 |
I want to find the first record of
so the result should look like this
id | source_id | first_id |
100 | 100 | |
101 | 100 | 100 |
102 | 102 | |
103 | 102 | 102 |
104 | 101 | 100 |
105 | 104 | 100 |
Thanx for helping!
Use recursive function in PQ
let
Fx = (id, src) =>
let pos = List.PositionOf(ID, src)
in if pos > -1 then @Fx(ID{pos}, Src{pos}) else id,
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwUNJRUorVATENgUyQAIRnhJAwBksYQXkmYJ4hlGcK5pkoxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, source_id = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"source_id", Int64.Type}}),
ID = #"Changed Type"[id], src=#"Changed Type"[source_id],
Traced = Table.AddColumn(#"Changed Type", "Root", each fx([id], [source_id]))
in
Traced
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
Hi Thanx for your reaction,
I can't get it working. I did try to copy your code in power query.
Can you add extra information on how to create the recursive function in Power Query?
Thanx
Hi try it :
first_id = IF(ISBLANK(LOOKUPVALUE('Table'[id], 'Table'[id], 'Table'[source_id])), 'Table'[id], LOOKUPVALUE('Table'[id], 'Table'[id], 'Table'[source_id]))
Hi Thanx for your reaction.
But this is n't going to work.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
45 | |
26 | |
22 | |
12 | |
8 |
User | Count |
---|---|
75 | |
51 | |
47 | |
16 | |
13 |