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

Geelhoed, Laura 41 Reputation points
2022-04-25T23:42:17.667+00:00

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 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!

Windows 365 Enterprise
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
40,132 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lu Dai-MSFT 28,431 Reputation points
    2022-04-26T01:49:56.237+00:00

    @Geelhoed, Laura Thanks for posting in our Q&A. For this issue, it is related to Power BI. I'm not a support engineer of Power BI and know little about it.

    Given this situation, it is suggested to post in Microsoft Power BI Community forum to get more accurate help. Here is the link:
    https://community.powerbi.com/t5/Forums/ct-p/PBI_Comm_Forums

    Thanks for your understanding and hope everything goes well with you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.