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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
NeverGiveUp
Frequent Visitor

I figured it out... thank you. Count NON Blank # of occurrences - even if it is a duplicate

I figured it out finally.  thank you.
So I was thinking more of the logic and I believe I need an IF statement maybe?  
Since in 1 single project 2 materials may be producing 2 brandcodes and I do want to count the number of brand codes if it is in a different project...

could you help me somehow incorporate this -

 

And I am not sure if I need to specify anything about the materials. 

I just don't want to count 2 brandcodes if that brandcode belongs to 2 different materials & is in the same project.  I don't want to include materials as a way to count, but it is what is causing the calculation to be off.

Would I use ALLEXCEPT maybe?

 

Would I use ALLEXCEPT maybe?

 

If projectid = project id, then count distinct (do not want duplicate brandcodes)

If project id <> project id, then count all (including duplicate brandcodes)


I am trying to get the total number of non-blank brandcodes in a table.

Unfortunately, everything I tried, either gives me the distinct count OR gives me a number that is higher the actual number (which appears to be linked to the columns that are a lower hierarchy in the matrix - the part #s).  But I am not sure why it is including those because they are not a part of the column I am focusing on.... including snapshot of this...
The result should be 11.  But I either get 10 (because this would be true if it were distinct.  However, I dont want distinct).

OR I get 16 because as mentioned earlier it is including another column in the calculation for some reason.

 

sample snapshot.JPG

Below is one of the things I tried, however this gives me 10 and it should be 11 because I have the same  brandcode that is in a differernt project ID #...

count BC =

SUMX(

    VALUES('PCMerge'[brandcodes]),

    IF('PCMerge'[brandcodes] <> BLANK(), 10))


 

TestCountBrandCodes =

VAR SummaryTable =

    ADDCOLUMNS ( VALUES ( 'PCMerge'[brandcodes]), "@value", [count BC])

RETURN

    SUMX(SummaryTable, [@value])

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @NeverGiveUp 

 

You need to calculate the distinct count of brandcodes per project id, then sum all of them. 

count BC =
SUMX (
    VALUES ( 'PCMerge'[Project ID] ),
    DISTINCTCOUNT ( 'PCMerge'[brandcodes] )
)

Hope this helps. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Unfortunately this gave me 60 ??

 

So I was thinking more of the logic and I believe I need an IF statement maybe?  
Since in 1 single project 2 materials may be producing 2 brandcodes and I do want to count the number of brand codes if it is in a different project...

could you help me somehow incorporate this -

 

And I am not sure if I need to specify anything about the materials.  I just don't want to count 2 brandcodes if that brandcode belongs to 2 different materials & is in the same project.  I don't want to include materials as a way to count, but it is what is causing the calculation to be off.

Would I use ALLEXCEPT maybe?

 

If projectid = project id, then count distinct (do not want duplicate brandcodes)

If project id <> project id, then count all (including duplicate brandcodes)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.