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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
NotMoike
Regular Visitor

Measure with containsstring and filters

Hello, im a total rookie when it comes to PBI and im stuck on a problem i can't find the logic to why it does what it does.

 

Im trying to model data from our ticketsystem and its a single table (Data) with no relationships.

 

Date = when the ticket was closed (hierarchy with Year, month, weekNR, day)

TicketID = unique value in numberformat

Agent = The agent who closed the ticket (An Agent can exist in multiple groups)

ActiveAgents = shows the flow on which agent handled the ticket. So in the ticket "123" the logic is that Sam from 1stline did something to the ticket and then Frank from "DWP" did something else and Ted closed the ticket. (Ted is a member of DWP). 

Group = The group who closed the ticket. 

ActiveGroup = Same logic as ActiveAgents, but with the group instead.

 

DateTicketIDAgentActiveAgentsGroupActiveGroup
2023-01-01123TedSam, FrankDWP1stline, DWP
2023-01-01124FrankFrank, Mike, Jules, Ted, Mike, TedDWPDWP
2023-01-02152MikeRoger, TedDWPBackoffice, DWP
2023-01-04163JulesMike, OizoDWPDWP, Tech, DWP

 

I have 3 slicers based on the date-hiearchy in the table.

Year, Month and Group.

 

I have a visual with "Agent", "count of TicketID" and i want to measure how many tickets the agents filtered out by the slicers actually handled regardless of which group they handled the ticket in.

 

So i created a measure

Handled.tickets.agent =
VAR SelectedAgent = SELECTEDVALUE(Data[Agent])
RETURN
CALCULATE(
    SUMX(
        FILTER(
            ALLSELECTED(Data),
            CONTAINSSTRING('Data'[ActiveAgents], SelectedAgent)
        ),
        1
    ),
    ALLSELECTED('Data'[Date]),
   -- Data[Agent] = SelectedAgent //If i add this i don't get the first error with "ghostAgents" but i do get the second error where the numbers are skewed)
)

--

 

I've tried various filters in above measure and parts of it work but not everything.

If i use the "yearslicer" it shows some agents correct, the "Green agent" did close 470 tickets and was involved in 491 tickets.

But i also get agents who did not close or handle any tickets that year (such as people who quit years ago but they are atleast were part of the group i filter on).

 

NotMoike_0-1690530399209.png

 

 

But with the same measure and an additional filter (Year + Month) i get an additional error

NotMoike_1-1690530693576.png

 

The yellow-agent did close 61 tickets in April of 2023, however, when i manually check how many tickets he was involved in the number should be 71. 

 

Im guessing im messing something up with the filters and putting filter on filter so the values gets skewed but i can't figure out how to solve it.

 

Any suggestions on how i should do this or what im doing wrong?

 

2 REPLIES 2
tamerj1
Super User
Super User

Hi @NotMoike 
You said the Group is in the slicer. So what do you mean by " regardless of which group they handled the ticket in"? Do you want to ignore the filter of the selected group(s)? 

Yes, kindof.

I want the "groupslicer" to just list the agents in that group (and with the additional filter of the date slicers. So if a agent closed a ticket in 2022 but never again, that agent wouldnt be visible if i "slice 2023" in the date. The value for "activeagents" should reflect the value regardless of the group in the slicer, but it needs to accomodate for the date-slice. If that makes sense

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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