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.
Suppose in table1, I have a column named 'predicate'. It contains boolean expression of the form 'column_name_of_table2 == value', I want to drill through table1 and show rows of table2 which satisfies the boolean expression.
Example-
Table1
Predicate |
student == 'stephan' |
course == 'CS101' |
Table 2
Student | Course |
stephan | CS213 |
not_stephan | CS101 |
When user click on the first predicate I want to show all rows related to stephan in Table2. How do I achieve this ?
Solved! Go to Solution.
HI @Prashant_Saroj,
As amitchandak said, 'Expression.Evaluate' function should help with your requirement. But it required you to do some additional steps.
1. Replace operator with power query operators:
Power Query M formula language / Operators
2. Replace your field names with raw table field names. (notice: power query is case-sensitive of field names)
3. Package field names with '[]' characters and concatenate your conditions with logic operator 'or' and add 'each' keyword at the start of the merged condition string.
ConditionString = "each "&Text.Combine(List.Transform(Condition[Predicate],each "["& Text.Insert(_,Text.Length(Text.Split(_," "){0}),"]"))," or ")
4. Add a filter step in your raw table steps, use Expression.Evaluate function to invoke processed condition string.
#"Filtered Rows" = Table.SelectRows(#"Changed Type", Expression.Evaluate(ConditionString,#shared))
Full Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKi5JLchIzFPSUXIONjI0VorViVbKyy+JRxY3NDBUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Student = _t, Course = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Student", type text}, {"Course", type text}}),
ConditionString = "each "&Text.Combine(List.Transform(Condition[Predicate],each "["& Text.Insert(_,Text.Length(Text.Split(_," "){0}),"]"))," or "),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", Expression.Evaluate(ConditionString,#shared))
in
#"Filtered Rows"
Regards,
Xiaoxin Sheng
HI @Prashant_Saroj,
As amitchandak said, 'Expression.Evaluate' function should help with your requirement. But it required you to do some additional steps.
1. Replace operator with power query operators:
Power Query M formula language / Operators
2. Replace your field names with raw table field names. (notice: power query is case-sensitive of field names)
3. Package field names with '[]' characters and concatenate your conditions with logic operator 'or' and add 'each' keyword at the start of the merged condition string.
ConditionString = "each "&Text.Combine(List.Transform(Condition[Predicate],each "["& Text.Insert(_,Text.Length(Text.Split(_," "){0}),"]"))," or ")
4. Add a filter step in your raw table steps, use Expression.Evaluate function to invoke processed condition string.
#"Filtered Rows" = Table.SelectRows(#"Changed Type", Expression.Evaluate(ConditionString,#shared))
Full Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKi5JLchIzFPSUXIONjI0VorViVbKyy+JRxY3NDBUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Student = _t, Course = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Student", type text}, {"Course", type text}}),
ConditionString = "each "&Text.Combine(List.Transform(Condition[Predicate],each "["& Text.Insert(_,Text.Length(Text.Split(_," "){0}),"]"))," or "),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", Expression.Evaluate(ConditionString,#shared))
in
#"Filtered Rows"
Regards,
Xiaoxin Sheng
@Prashant_Saroj , refer if this can help
https://blog.crossjoin.co.uk/2015/02/06/expression-evaluate-in-power-querym/
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 |
---|---|
104 | |
96 | |
79 | |
67 | |
62 |
User | Count |
---|---|
137 | |
106 | |
104 | |
81 | |
63 |