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 All,
I am trying to create a measure that will only display the rows containing text from the other table’s selected items. I build a very simple illustration as attached.
Say if I have two tables and I select both “apple” and “orange” in the first table, the Description table only displays rows with ID 1 and 2.
If I select all Fruit, the Description table only display rows with ID 1, 2, and 4.
If I select only pork, the Description table will show nothing.
My first question is why do you need to filter items that does not belong to the fruit category?
I propose the following approach:
= Table.AddColumn(#"Changed Type", "Custom", each List.Accumulate(
List.Numbers(0, Table.RowCount(Table1)),
[Description],
(state, current) =>
if Text.Contains (state, Table1[Fruit]{current}, Comparer.OrdinalIgnoreCase) then Table1[Fruit]{current} else state))
this expression searches if in the description there is any coincidence with the list of fruits, if there is, it returns the fruit, if not, there is no change.
3. To categorize the results, I add another column with the following expression:
= Table.AddColumn(#"Added Custom", "Custom.1", each List.Accumulate(
List.Numbers(0, Table.RowCount(Table1)),
[Description],
(state, current) =>
if Text.Contains (state, Table1[Fruit]{current}, Comparer.OrdinalIgnoreCase) then "Fruit" else state))
4. apply and close the power query editor
5 use the visual
Hi @jiandaoz
Try something like the approach below.
Make sure you add a measure filter in order for the table to only show the "Selected" result
Thank you first! in my real example, I have hundreds of categories of "Fruit". Is there any other way I can do this easily?
Hi there. Perhaps a more veteran member can come up with something in DAX. (Power query can also be useful).
I can make it work if the selection is only for 1 item... Meaning the user only selects "apple" or only selects orange: (you can use Values or concatenatex again)
CONTAINSSTRING(CONCATENATEX('Table 2','Table 2'[Description]),VALUES Table 1 [Fruit]))
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 |
---|---|
47 | |
24 | |
20 | |
15 | |
13 |
User | Count |
---|---|
51 | |
46 | |
39 | |
19 | |
19 |