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
Leigh_123
Frequent Visitor

SUMX with Distinct count on different column

Hi all,

 

I have calculation that i have created from online research that counts string column ('Query1'[Business(es) Area]) and filters by a predefined table 'Business area filter':

 

I want to be able to have a distinct count of the SUMX but based on a different column in 'Query1', is this something that is possible?

 

current dax below

 

 

 

 

Business area =
VAR __SearchTerms =
    ADDCOLUMNS (
        'Business area filter',
        "Count",
            COUNTROWS (
                FILTER (
                    'Query1',
                    FIND ( 'Business area filter'[Business Area reference],'Query1'[Business(es) Area],, 0 ) > 0
                )
            )
    )
RETURN
    SUMX ( __SearchTerms, [Count] )

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Leigh_123 ,

Please have a try.

Business area =
VAR __SearchTerms =
    ADDCOLUMNS (
        'Business area filter',
        "Count",
            COUNTROWS (
                FILTER (
                    'Query1',
                    FIND ( 'Business area filter'[Business Area reference],'Query1'[Your column name],, 0 ) > 0
                )
            )
    )
RETURN
    SUMX ( DISTINCT(__SearchTerms, 'Query1'[Your column name]), [Count] )

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

4 REPLIES 4
Anonymous
Not applicable

Hi @Leigh_123 ,

Please have a try.

Business area =
VAR __SearchTerms =
    ADDCOLUMNS (
        'Business area filter',
        "Count",
            COUNTROWS (
                FILTER (
                    'Query1',
                    FIND ( 'Business area filter'[Business Area reference],'Query1'[Your column name],, 0 ) > 0
                )
            )
    )
RETURN
    SUMX ( DISTINCT(__SearchTerms, 'Query1'[Your column name]), [Count] )

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

IDBusiness AreaCountry
1Tax; ConsultingKorea
2TaxFrance
3AuditUK
4AuditIreland
5Audit; Tax; ConsultingAustralia
6TaxChina
7Audit; TaxGermany
8ConsultingZimbabwe
9Consulting; TaxSouth Africa
10Consulting; TaxUS
11AuditSwitzerland
12AuditSwitzerland
13Financial AdvisoryIndia
14Risk AdvisoryJapan
15Audit; TaxGermany
16Risk AdvisorySpain
17Financial Advisory; AuditNorway
18Audit; TaxSpain
19Enabling AreaEgypt
20Enabling AreaEgypt
21Audit; TaxBelgium
22TaxGreece
23TaxItaly
24Conulting; Tax; AuditTurkey
25Audit; Enabling AreaPortugal
26AuditLatvia
27Audit; TaxLithuania
28Audit; Tax; Consulting; Risk AdvisoryGeorgia

29

Financial Advisory; Audit; TaxBarbados

 

Providing the attached sample data. Escentially i need a distint count of "Business Area" based on "Country". I can do this with individual dax for each bsiness area:

 

count (A&A) = 
Calculate(
    DISTINCTCOUNT('Dummy data'[Country]),
    CONTAINSSTRING('Dummy data'[Business Area],"Audit"))

 

However if i want to add this to a bar chart i get a mess:Distinct count.png

I am looking to achieve the above in the format below:Count.png

I achieved this with the folowing Dax:

 

Business area percentage = 
VAR __SearchTerms =
    ADDCOLUMNS (
        'Business area filter',
        "Count",
            COUNTROWS (
                FILTER (
                    'Dummy data',
                    FIND ( 'Business Area Filter'[Business Area reference],'Dummy data'[Business Area],, 0 ) > 0
                )
            )
    )
RETURN
    SUMX ( __SearchTerms, [Count] )

 

Is there any way to edit this to count distinct? Apologies, i am unable to provide pbix.

 

Thank you in advance

I would recommend you solve that issue in Power Query to bring your source data into a usable format.  Then the visuals will work automatically.

lbendlin_0-1690458078679.png

 

Note you have a data quality issue with "Conulting".

See attached

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.