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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count of values in a column

I've created a table from the fields Source and Preparer. If I want to see those sources where there is only one preparer what's is the best way to do it 

 

Like the Sources "MN", "RT" and "PO". 

Please note that this is a table I created from my dataset, so if I take the count of Source as the third column that is going to be a huge number. 

 

SourcePreparer
ABJune
ABJane
MNJune
SSKim
SSLee
SSJim
RTKim
POJune
POJune
RTKim

 


The outcome should be like 

SourcePreparer
MNJune
RTKim
POJune


Thanks in advance!

1 ACCEPTED SOLUTION

@Anonymous you could apply the Power Query solution to other tables/fields. It's a little difficult to answer completely without a complete picture of your entire scenario.

 

For a DAX solution, you could do something with this...

 

Table 2 =
FILTER (
    SUMMARIZECOLUMNS (
        'Table'[Source],
        "Count Distinct", DISTINCTCOUNT ( 'Table'[Preparer] )
    ),
    [Count Distinct] = 1
)

 

Note, this is not a calculated column, this was added as a table via the modelling tab >> New table option but the pattern could equally be added into a calculated column or measure. 

I would need more time than I can spend at the moment, maybe someone with more DAX skills could adapt this for you.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

View solution in original post

13 REPLIES 13
smpa01
Super User
Super User

@Anonymous  a DAX Measure solution

 

newMeasure = 
CALCULATE (
    DISTINCTCOUNT ( 'Table 1'[Preparer] ),
    FILTER (
        GROUPBY ( 'Table 1', 'Table 1'[Source], 'Table 1'[Preparer] ),
        CALCULATE (
            DISTINCTCOUNT ( 'Table 1'[Preparer] ),
            ALLEXCEPT ( 'Table 1', 'Table 1'[Source] )
        ) = 1
    )
)

 

smpa01_0-1632932125299.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
KNP
Super User
Super User

Hi @Anonymous, 

 

You could try this Power Query Solution.

Let me know if this helps or if you have further questions.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!
Anonymous
Not applicable

@KNP  thanks for your response,

There is only one Source in Table2 from your solution, but I need 3 sources i.e. "MN", "RT" and "PO" where there is only one preparer for these sources 

@Anonymous - I understand now.

I've updated the PBIX file. Please have another look.

 

Basically this line...

#"Grouped Rows" = Table.Group(Source, {"Source"}, {{"Count", each Table.RowCount(List.Distinct(_[Preparer])), Int64.Type}, {"All", each _, type table [Source=nullable text, Preparer=nullable text]}}),

Gets the distinct count.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!
Anonymous
Not applicable

@KNP  thanks,

But is there any way to use calculated columns as I've to apply this solution to more fields and that too some are in other tables?  

@Anonymous you could apply the Power Query solution to other tables/fields. It's a little difficult to answer completely without a complete picture of your entire scenario.

 

For a DAX solution, you could do something with this...

 

Table 2 =
FILTER (
    SUMMARIZECOLUMNS (
        'Table'[Source],
        "Count Distinct", DISTINCTCOUNT ( 'Table'[Preparer] )
    ),
    [Count Distinct] = 1
)

 

Note, this is not a calculated column, this was added as a table via the modelling tab >> New table option but the pattern could equally be added into a calculated column or measure. 

I would need more time than I can spend at the moment, maybe someone with more DAX skills could adapt this for you.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!
CNENFRNL
Community Champion
Community Champion

Calculated column

Count = COUNTROWS( FILTER( Table1, Table1[Source] = EARLIER( Table1[Source] ) ) )

Screenshot 2021-06-07 195824.png 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi @CNENFRNL  thanks for your reply

But when I apply this in my dataset I got a huge value for the sources MN, RT and PO. I think based on your formula I get the total count of Sources in my dataset, 

I've updated my question for a better understanding 

Anonymous
Not applicable

I've applied the formula to the updated dataset and now I get this count

Adarsh_R3_1-1623090105828.png

Even though the Sources RT and PO has only one preparer, the count shows 2. 

aj1973
Community Champion
Community Champion

Hi @Anonymous 

is this good!?

aj1973_1-1623091504232.png

 

It is a measure though, not an added column

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

@aj1973 thanks,

If I filter on the basis of count I'll get the source "MN", but in fact, there is "RT" and "PO" where there is only one preparer. even though they are occurring multiple times in the record, still RT and PO only contains 1 preparer 

aj1973
Community Champion
Community Champion

@Anonymous 

Can you screen shot or represent the out come you want to see?

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

@aj1973  updated my question with the outcome 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors