Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
I am struggling with something that may be simple to solve. By year and month, I want to make a dynamic bar chart to present counts by a distinct ID that fits criteria based on columns Filter1 and Filter2. For simplicity, I am only using as an example a few lines from a large table, assuming all are from the same year and month.
ID | Filter1 | Filter2 |
ID1 | A | D |
ID1 | B | D |
ID2 | A | F |
ID2 | B | E |
ID3 | A | D |
ID3 | B | F |
ID4 | B | D |
ID4 | C | D |
ID5 | B | D |
ID5 | C | E |
ID6 | A | D |
ID6 | B | D |
ID6 | C | D |
An example of questions I am trying to answer and visualize are
1-How many times A and B were concomitantly present in an ID? Answer = 4 (ID1;ID2;ID3;ID6). This would later be used to answer a similar question applied to B and C, or for the three of them A, B, and C.
2- How many times A and B were concomitantly present in an ID, and A had Filter2= D and B had Filter2= D?
Answer= 2 (ID1; ID6)
2- How many times A and B were concomitantly present in an ID, and A had Filter2= D and B had Filter2= E?
Answer= 0
Any help in how I could do this is welcome!
Solved! Go to Solution.
@Giovani might these code help
ID_Count:=COUNTROWS (
FILTER (
VALUES ( SampleData[ID] ),
VAR _Filter1 =
CALCULATETABLE (
VALUES ( SampleData[Filter1] ),
ALLEXCEPT ( SampleData, SampleData[ID] )
)
RETURN
AND ( CONTAINSROW ( _Filter1, "A" ), CONTAINSROW ( _Filter1, "B" ) )
)
)
----------------------------
ID_Count2:=COUNTROWS (
FILTER (
VALUES ( SampleData[ID] ),
VAR _Filter1 =
CALCULATETABLE (
SUMMARIZE ( SampleData, SampleData[Filter1], SampleData[Filter2] ),
ALLEXCEPT ( SampleData, SampleData[ID] )
)
RETURN
AND ( CONTAINSROW ( _Filter1, "A", "D" ), CONTAINSROW ( _Filter1, "B", "D" ) )
)
)
----------------------
ID_Count3:=COUNTROWS (
FILTER (
VALUES ( SampleData[ID] ),
VAR _Filter1 =
CALCULATETABLE (
SUMMARIZE ( SampleData, SampleData[Filter1], SampleData[Filter2] ),
ALLEXCEPT ( SampleData, SampleData[ID] )
)
RETURN
AND ( CONTAINSROW ( _Filter1, "A", "D" ), CONTAINSROW ( _Filter1, "B", "E" ) )
)
)
@Giovani might these code help
ID_Count:=COUNTROWS (
FILTER (
VALUES ( SampleData[ID] ),
VAR _Filter1 =
CALCULATETABLE (
VALUES ( SampleData[Filter1] ),
ALLEXCEPT ( SampleData, SampleData[ID] )
)
RETURN
AND ( CONTAINSROW ( _Filter1, "A" ), CONTAINSROW ( _Filter1, "B" ) )
)
)
----------------------------
ID_Count2:=COUNTROWS (
FILTER (
VALUES ( SampleData[ID] ),
VAR _Filter1 =
CALCULATETABLE (
SUMMARIZE ( SampleData, SampleData[Filter1], SampleData[Filter2] ),
ALLEXCEPT ( SampleData, SampleData[ID] )
)
RETURN
AND ( CONTAINSROW ( _Filter1, "A", "D" ), CONTAINSROW ( _Filter1, "B", "D" ) )
)
)
----------------------
ID_Count3:=COUNTROWS (
FILTER (
VALUES ( SampleData[ID] ),
VAR _Filter1 =
CALCULATETABLE (
SUMMARIZE ( SampleData, SampleData[Filter1], SampleData[Filter2] ),
ALLEXCEPT ( SampleData, SampleData[ID] )
)
RETURN
AND ( CONTAINSROW ( _Filter1, "A", "D" ), CONTAINSROW ( _Filter1, "B", "E" ) )
)
)
Many thanks to @wdx223_Daniel this is perfect and is exactlly what I was looking for!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
13 | |
12 | |
11 | |
9 |