question

GeelhoedLaura-1586 avatar image
0 Votes"
GeelhoedLaura-1586 asked PRADEEPCHEEKATLA-MSFT edited

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

power-query-not-supportedwindows-365-enterprise
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LuDaiMSFT-0289 avatar image
0 Votes"
LuDaiMSFT-0289 answered LuDaiMSFT-0289 commented

@GeelhoedLaura-1586 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.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have reposted in the correct forum! Thanks for your help!

0 Votes 0 ·
LuDaiMSFT-0289 avatar image LuDaiMSFT-0289 GeelhoedLaura-1586 ·

@GeelhoedLaura-1586 You're welcome. Hope everything goes well with you.

Thanks for your kindness and have a nice day. : )

1 Vote 1 ·