Forum Discussion
Mikelytics
3 years agoResident Rockstar
Get Table Object based on String
Dear community, following topic. Lets say I have 3 different tables (dummy data only, the original table have multiple columns and more rows): Furthermore, I have...
- 3 years ago
Hi Mikelytics ,
you could use the function Expression.Evaluate for it, but this won't work if you want to refresh the report in the PBI service.
Instead, I would recommend to append all 3 tables into 1 and create a "TableName" column to distinguish between them. Then you can use a Table.SelectRows command to filter the relevant table for each row, as this allows you to pass a text string.
AntrikshSharma
3 years agoCommunity Champion
Mikelytics You can use #sections for this, it wil return all the queries and then you can filter based on the name.
let
Source = Table.FromRows (
Json.Document (
Binary.Decompress (
Binary.FromText (
"i45WCijKTylNLilWitWJVgpOzEmFsJxLi0vyc1OLgLxYAA==",
BinaryEncoding.Base64
),
Compression.Deflate
)
),
let
_t = ( ( type nullable text ) meta [ Serialized.Text = true ] )
in
type table [ #"Table Name" = _t ]
),
ChangedType = Table.TransformColumnTypes ( Source, { { "Table Name", type text } } ),
AddedCustom = Table.AddColumn (
ChangedType,
"Custom",
( OT ) =>
try
Table.SelectRows (
Record.ToTable ( #sections[Section1] ),
( IT ) => IT[Name] = OT[Table Name]
)[Value]{0}
otherwise
null
)
in
AddedCustom