Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
LauraG8
Frequent Visitor

How to filter a report page in Power BI with a measure?

This is my first attempt at writing more complex DAX measures.

I have table with incidents by student. An incident can have multiple students and a student can have multiple incidents.
I have the below measure to calculate the number of student that have 2 - 6 incidents for the selected period.

 

Tier 2 :=
VAR IncidentByStudentCount =
SUMMARIZE (
FILTER (
IncidentInvolvement,
AND (
IncidentInvolvement[IncidentInvolvementType] = "Involved",
IncidentInvolvement[IncidentCategory] = "Major Negative"
)
),
IncidentInvolvement[SchoolCode],
IncidentInvolvement[StudentIdentifier],
"CountInvolvement", COUNT ( IncidentInvolvement[IncidentCode] )
)
VAR Tier2 =
FILTER (
IncidentByStudentCount,
AND ( [CountInvolvement] >= 2, [CountInvolvement] <= 6 )
)
RETURN
COUNTROWS ( Tier2 ) + 0

Now I want to filter my report page and only show data for the students that have between 2 to 6 incidents for the selected period. What would be the best way to do this?

 

I tried to solve it with the below measure.

 

Tier 2 Negative Incidents :=

VAR IncidentByStudentCount =

SUMMARIZE(

FILTER(

IncidentInvolvement,

AND (IncidentInvolvement[IncidentInvolvementType] = "Involved",

IncidentInvolvement[IncidentCategory] = "Major Negative")

),

IncidentInvolvement[SchoolCode],

IncidentInvolvement[StudentIdentifier],

"CountInvolvement"

COUNT(IncidentInvolvement[IncidentCode])

)VAR Tier2Table =

FILTER(

IncidentByStudentCount,

AND ([CountInvolvement] >= 2,

[CountInvolvement] <= 6)

)

VAR Tier2TableFilter =

CALCULATETABLE(

VALUES(IncidentInvolvement[StudentIdentifier]),

Tier2Table,

ALLSELECTED()

)

VAR Tier2NegativeIncidents =

CALCULATE(

COUNT(IncidentInvolvement[IncidentIdentifier]),

AND( IncidentInvolvement[IncidentInvolvementType] = "Involved",

IncidentInvolvement[IncidentCategory] = "Major Negative"

),

Tier2TableFilter)

RETURN

Tier2NegativeIncidents

 

This works when I have a visual by student. However, for my other visuals where I want to show the number of incidents by location etc. it doesn't work, because it will only show locations for those students where their incident location has between 2-6 incidents. So it executes the filter "AND ([CountInvolvement] >= 2,[CountInvolvement] <= 6)" over the location as well. Clearly I am doing something wrong. I hope someone can help me out!

 

@dax

1 ACCEPTED SOLUTION

Hi,

Download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

12 REPLIES 12
Anonymous
Not applicable

Hi @LauraG8 ,

 

Did you want to use a measure as the page-level filter or use a measure to return the filtered results?

Is it possible to provide some dummy data and expected results?

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Stephen, Thanks for reaching out!

Please see the dummy data below;

IncidentIDStudentCategoryBehaviourLocationPeriodAcademic year
100BillyMajorBullyingPlaygroundLunch Break6
100DylanMajorBullyingPlaygroundLunch Break7
100KateMajorBullyingPlaygroundLunch Break7
110DylanMajorNon-ComplianceClassroomMorning session7
150DylanMinorInappropriate languageClassroomAfternoon session7
155DylanMajorPhysical ContactPlaygroundRecess7
155BillyMajorPhysical ContactPlaygroundRecess6
225SusanMajorPhysical ContactPlaygroundAfternoon session8
225DylanMajorPhysical ContactPlaygroundAfternoon session7

 

I have a page with the following (dummy) visuals;

LauraG8_1-1651188094220.png

LauraG8_2-1651188136139.pngLauraG8_3-1651188155853.png

LauraG8_4-1651188184672.png

 

I also have a card visual with the Tier 2 measure that calcualates the number of students that have between 2 - 6 Major incidents for the selected time frame (Year, term, week). In the dummy data that would be 2 (Dylan with 4 and Billy with 2). Now I would like to have a filter option (button) to only show data for the major incidents for students that have between 2-6 major incidents. In the dummy data that would be Dylan and Billy, with 6 major incidents. Behaviour visual would show 2 bullying, 1 Non-Compliance, 3 Physical contact. Location visual: 5 Playground, 1 Classroom. Period visual: 2 Lunchbreak, 1 Morning Session, 2 Recess and 1 Afternoon session.

I hope this makes sense!

 

Thanks!

 

Hi,

Download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

Thank you for provideing a solution. However, due to security restrictions I can't download your file. Can you please explain the solution/ write it out? Did you use a measure and if so can you provide me with the DAX code? Thanks!

There are way too many steps to write down.  Please use another connection to download the file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

I have downloaded the file and had a bit of a play with it.

What I want to achieve in my report is slice by bracket. So when I click on the 2-6 bracket I just want to see data for Billy and Dylan. I don't seem to be able to do that. I hope you can help me out with this. Thank you! 🙂

 

LauraG8_1-1652742719535.png

 

LauraG8_0-1652742677876.png

 

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

Thank you for your very swift reply! 🙂

That works a bit better. However, when I add behaviour to the table and select 2-6 incidents I only see Dylan with 2 incidents for Physical contact. (see below)

 

LauraG8_0-1652744987752.png

I would like to see all data for both Billy and Dylan as per below example.

LauraG8_1-1652745135716.png

I hope that makes sense.

 

Thanks,

Laura

 

Hi,

This is the closest i can get it to.  Download the PBI file from here.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks so much Ashish! 🙂👍

amitchandak
Super User
Super User

@LauraG8 , You need to segmentation for that

 

Dynamic segmentation -Measure to Dimension conversion: https://youtu.be/gzY40NWJpWQ

 

Assume you have measure

 

Bucket/Segment code
measure
Measure = Count(Table[productid]) /

 

Create new Table
bucket = Generateseries(1,100,1)

 

new Measure
Countx(filter(Values(Table[user]), [Measure ] = max(bucket[Value])), [User])

 

between bucket

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for reaching out and sending your solution. Unfortunately, it's not the solution I was looking for in this instance.

Please see my further explantion on what I would like to achieve in my reply to Stephen Tao. Hope that explains it a bit better!

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors