Forum Discussion
Filter by a Measure
- 1 year ago
Hi duesouth ,
Thank you for reaching out to Microsoft Fabric Community.
Above error ( The expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression.) can be fixed by replacing it with the below measure. Establish the relation ship between Behaviour and pupil_data using external ID.
NumberInHub_Column =CALCULATE (COUNTROWS (FILTER (RELATEDTABLE ( Behaviour ),Behaviour[Behaviour Type] IN {"B7 The Learning Hub","B7 The Learning Hub - 3 Strikes","B7 The Learning Hub - Lates","B7 The Learning Hub - No PROUD Card"})))If you have any further questions, please feel free to share them along with a sample output. We're happy to help.If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you!!
Hi duesouth ,
Power BI doesn't allow you to use a measure as a slicer or directly in visual-level filters because measures are context-dependent and recalculated on the fly. To filter the average grade card by how often a pupil has been sent to the Hub, you need a calculated column that counts the number of times each pupil has been to the Hub. This column can then be used in slicers or as a filter on visuals.
You can add the following calculated column to your Pupil_Data table or whichever table you're using as your base for visuals:
NumberInHub_Column =
CALCULATE (
COUNTROWS ( Behaviour ),
FILTER (
Behaviour,
Behaviour[Behaviour Type] IN {
"B7 The Learning Hub",
"B7 The Learning Hub - 3 Strikes",
"B7 The Learning Hub - Lates",
"B7 The Learning Hub - No PROUD Card"
}
),
Behaviour[External ID] = Pupil_Data[External ID]
)
Once this column is created, you can use it as a visual-level filter in your average grade card. For instance, set the filter to only include pupils with NumberInHub_Column >= 5 to evaluate the impact on students with frequent Hub events. Your average grade measure like this:
Average Grade = AVERAGE(Assessment[Grade])
will now respond to the filter and only show the average for students who meet the specified Hub visit threshold. If you want slicer interactivity, you can also create a GENERATESERIES table and use the selected value from that slicer to filter visuals based on this calculated column. This avoids the issues you faced with measures not being accepted in slicers or filters and gives you the control you need.
Best regards,
Thanks for the reply. I've tried to put in the DAX, but it's returning the error:
"The expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression."
The error is under Pupil_Data[External ID]
Any ideas? Thank you!
- v-sathmakuri1 year agoCommunity Support
Hi duesouth ,
Thank you for reaching out to Microsoft Fabric Community.
Above error ( The expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression.) can be fixed by replacing it with the below measure. Establish the relation ship between Behaviour and pupil_data using external ID.
NumberInHub_Column =CALCULATE (COUNTROWS (FILTER (RELATEDTABLE ( Behaviour ),Behaviour[Behaviour Type] IN {"B7 The Learning Hub","B7 The Learning Hub - 3 Strikes","B7 The Learning Hub - Lates","B7 The Learning Hub - No PROUD Card"})))If you have any further questions, please feel free to share them along with a sample output. We're happy to help.If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you!!
- duesouth1 year agoHelper I
Many thanks for taking the time to help - much appreciated!