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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
sam-biomodal
New Member

Creating a filter that keeps & counts all other records for the same ID

Hey all, I'm hoping that someone can help me create a filter that can help me do dynamic cross-referencing:

 

My data structure is like this:

IDCategory
01Blue
01Green
01Black
02Blue
02Red
03Yellow
03Red
03Blue
03White

 

What I am trying to get is a dynamic report where if I select a category, i.e. Red, I will be able to see what other categories are present (and count them) for IDs that also had red as a category. In the example above, IDs 2 & 3 have Red, so 2 & 3 would be returned and I'll be able to then do a count on the remaining categories, i.e. blue = 2, yellow = 1, white = 1

 

Ideally, I would have the filter category as a slicer widget and then show the count of categories in a bar chart.

 

Any help would be greatly appreciated, thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,@sam-biomodal 

Regarding the issue you raised, my solution is as follows:
1. Create a table with the same values as the original table as a virtual table, the name of the original table is "cross-referencing" and the name of the virtual table is "Table". Select the value of the "Table" table as the slicer.

2. Based on my understanding of your requirements, I have created the following measure:

 

Measure = 
VAR color=SELECTEDVALUE ('Table'[Category])
VAR ID1 =
    CALCULATETABLE (
        VALUES ( 'cross-referencing'[ID]),
        FILTER ( ALLSELECTED ( 'cross-referencing' ), 'cross-referencing'[Category] = color )
    )
RETURN
    CALCULATE (
        COUNT ( 'cross-referencing'[ID]),
        FILTER ( 'cross-referencing', 'cross-referencing'[ID] IN ID1 && 'cross-referencing'[Category]<> color )
    )

 

3.Change the visualization from a table to a bar chart and change the position of the values to measure:
vlinyulumsft_0-1715335370096.png

4.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1715335370100.png

vlinyulumsft_2-1715335380883.png

 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi,@sam-biomodal 

Regarding the issue you raised, my solution is as follows:
1. Create a table with the same values as the original table as a virtual table, the name of the original table is "cross-referencing" and the name of the virtual table is "Table". Select the value of the "Table" table as the slicer.

2. Based on my understanding of your requirements, I have created the following measure:

 

Measure = 
VAR color=SELECTEDVALUE ('Table'[Category])
VAR ID1 =
    CALCULATETABLE (
        VALUES ( 'cross-referencing'[ID]),
        FILTER ( ALLSELECTED ( 'cross-referencing' ), 'cross-referencing'[Category] = color )
    )
RETURN
    CALCULATE (
        COUNT ( 'cross-referencing'[ID]),
        FILTER ( 'cross-referencing', 'cross-referencing'[ID] IN ID1 && 'cross-referencing'[Category]<> color )
    )

 

3.Change the visualization from a table to a bar chart and change the position of the values to measure:
vlinyulumsft_0-1715335370096.png

4.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1715335370100.png

vlinyulumsft_2-1715335380883.png

 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.