The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi Community,
Here is my data model
Tickets-*Bridge*-Tags
I need to filter (or basically distinct count) a set of tickets that are labeled with a set of tags.
For example - tags I may be interested in might be "help" and "power bi" and I need all tickets that have them both.
I know I can do something like
_ticketsCount = CALCULATE(DISTINCTCOUNT('Tickets'[TicketID]), CALCULATETABLE('Tickets','Tags'[TagName]= "help"),CALCULATETABLE('Tickets','Tags'[TagName]= "power bi"))
my goal is to make the selection of tags somehow interactive, so I add a table with tags of interest and my formula becomes
_ticketsCountInteractive = CALCULATE(
DISTINCTCOUNT('Tickets'[TicketId]),
CALCULATETABLE('Tickets',CONTAINSROW(ALLSELECTED(TagsOfInterest[TagName]),'Tags'[TagName]))
)
my problem is - calculatetable returns all tickets that have at least one tag (from the selected from tags of interest table), but not only tickets that have both tags on them..
any suggestions? is that achievable ? should I maybe look at it from another angle?
any thoughts are highly appreciated.
thanks
Solved! Go to Solution.
Thanks for the answer @Anonymous .
Looks similar to what I ended up with. I had to add a group be/having analogue to make this work.
It works, but you can not break that down by tag (not my need though) for obvious reasons.
_m3 = CALCULATE(DISTINCTCOUNT(Bridge[TicketId]),
filter(
SUMMARIZE(
filter(
bridge
,related(Tags[TagName]) in ALLSELECTED(TagsOfInterest[TagName]))
,Bridge[TicketId]
,"rowcount",COUNT(Bridge[TagId]))
,[rowcount] = countrows(ALLSELECTED(TagsOfInterest[TagName]))))
@YuriyM , Create an inactive many to many join between ticket and tags.
The use then when you want to filter tags
example
_ticketsCount = CALCULATE(DISTINCTCOUNT('Tickets'[TicketID]), Filter('Tickets','Tags'[TagName] in{ "help", "power bi"}) , userelation('Tickets'[ID],'Tags'[TicketID]))
or
_ticketsCount = CALCULATE(DISTINCTCOUNT('Tickets'[TicketID]), userelation('Tickets'[ID],'Tags'[TicketID]))
// The bridge table does contain
// TickeID and TagID and that's
// enough to calculate what you want.
// Let's say that you select several
// tag names from the Tags table...
[# Tickets With Selected Tags] =
var __numOfTags = COUNTROWS( Tags )
var __ticketsWithNumOfTags =
COUNTROWS(
FILTER(
DISTINCT( Bridge[TicketID] ),
CALCULATE(
COUNTROWS( Bridge ) = __numOfTags
)
)
)
return
__ticketsWithNumOfTags
Thanks for the answer @Anonymous .
Looks similar to what I ended up with. I had to add a group be/having analogue to make this work.
It works, but you can not break that down by tag (not my need though) for obvious reasons.
_m3 = CALCULATE(DISTINCTCOUNT(Bridge[TicketId]),
filter(
SUMMARIZE(
filter(
bridge
,related(Tags[TagName]) in ALLSELECTED(TagsOfInterest[TagName]))
,Bridge[TicketId]
,"rowcount",COUNT(Bridge[TagId]))
,[rowcount] = countrows(ALLSELECTED(TagsOfInterest[TagName]))))
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
18 | |
18 | |
17 | |
15 | |
13 |
User | Count |
---|---|
36 | |
34 | |
19 | |
18 | |
16 |