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.
I would like to try dynamic expanding columns in M code.
The code is:
fxFactorial = (RowCount as number, Tnumber as number, tbl as table) =>
let
displayname = "disPath" & Text.From(Tnumber),
childrenname = "children" & Text.From(Tnumber),
prevchildname = "children" & Text.From(Tnumber-1) ,
prevstep = tbl ,
Source2 = Table.ExpandListColumn( prevstep, prevchildname),
#"Added disPath2" = Table.AddColumn(Source2, displayname, each Record.Field(prevchildname,"displayPath") ),
#"Added children2" = Table.AddColumn(#"Added disPath2", childrenname, each try Record.Field([children1],"children") otherwise null ),
ColRowCount = List.NonNullCount( #"Added children2"[children2]),
titlenumber = Tnumber + 1,
subresult = if titlenumber > 2 then @fxFactorial(ColRowCount, titlenumber, #"Added children2") else #"Added children2"
in
#"Added disPath2"
But, I'm getting an error stating like We cannot convert the value "children1" to Record
Much appreciated it if someone showed some light on this query.
You are using the prevchildname variable (a text value) in a function that expects a record (Record.Field).
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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 |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |