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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Lednum861
New Member

Count distinct text in different columns

Hi

I'm very new to BI. I have my database setup similar to the table below. I want to use 2 tools in BI. One is a slicer and the other is a visual that counts and provides a total. I know how to use both tools but I can't get the count visual to return the corrent value.

Consider the data below...I want to put the 'part #' in the slicer. If I click on part # 111 in the slicer, I want the counter to return a value of 2 (2 distinct countries). If I click on 222 in the slicer, I want the counter to return a value of 1 (1 distinct country). Same for part # 333 (1 distinct country). 444 would return a value of 2 and 555 a value of 1.  Is this possible? Thank you very much for your time and help!!

Capture.PNG

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@Lednum861

 

Hi, try using this Dax:

 

Measure =
COUNTROWS (
    DISTINCT (
        UNION (
            FILTER ( VALUES ( Table1[MFR1 Country] ), Table1[MFR1 Country] <> BLANK () ),
            FILTER ( VALUES ( Table1[MFR2 Country] ), Table1[MFR2 Country] <> BLANK () )
        )
    )
)



Lima - Peru

View solution in original post

5 REPLIES 5
bblais
Resolver III
Resolver III

I would recommend that you pivot your data in the Edit Queries screen, something like this:

 

The table starts out looking like this:

Capture.PNG

 

Select the Part # column ONLY, and then choose Unpivot Other Columns in the Transform Ribbon:

 

Capture2.PNG

 

Then it will look like this:

 

Capture3.PNG

 

Then rename your columns to Manufacturer and Country and close and apply.  Now you can add a measure like this:

Country Count = DISTINCTCOUNT(Manufacturers[Country])

And use this measure in a table or other visual like this:

 

Capture4.PNG

Your solution worked perfectly. Thank you very much!

And I also fully support @Vvelarde's solution as well if you want your visuals to look more like this:

 

Capture5.PNG

Vvelarde
Community Champion
Community Champion

@Lednum861

 

Hi, try using this Dax:

 

Measure =
COUNTROWS (
    DISTINCT (
        UNION (
            FILTER ( VALUES ( Table1[MFR1 Country] ), Table1[MFR1 Country] <> BLANK () ),
            FILTER ( VALUES ( Table1[MFR2 Country] ), Table1[MFR2 Country] <> BLANK () )
        )
    )
)



Lima - Peru

Yes, this worked. Thank you so much. I actually tried your solution and the solution in the other post I received and both work perfectly. Thank you!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.