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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure that counts items with multiple values

Hi everyone,

 

What code would you use to create a measure for the following?

 

I need to know how many "Codes" have >1 Values within the column.

I would then input this measure into a tile, to display the number of "Codes" that have >1 Values.

 

In the screenshot below, AA123 has 1 value (ie. 5). BB987 has 3 values (ie. 10, 12, 14). CC000 has 1 value (ie. 20). DD999 has 3 values (ie. 30, 31, 32).

 

The final output should be 2; BB987 and DD999 has 3 non-duplicate values.

 

Test.JPG

 

I have tried something like this, but to no avail:

DISTINCTCOUNT_Code = CALCULATE(DISTINCTCOUNTNOBLANK(SAMPLE_TABLE[CODE]), FILTER(SAMPLE_TABLE, ...))

 

Any help would be appreciated!

Thanks!

4 REPLIES 4
Anonymous
Not applicable

measure=calculate(distinctcount(table[Column]),filter(table,table[Column1]>1))

 

Add column and measure into table visual.

 

Note Replace column and column1 with your column names.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Anonymous
Not applicable

Hi PR20048119,

 

Thanks for the reply.

 

I tried the code you suggested;

Sample_Measure = CALCULATE(DISTINCTCOUNT(Sheet1[Code]),FILTER(Sheet1,Sheet1[Value]>1))

 

However, it does not provide the correct output (see screenshot below).

 

1.JPG

 

The output should be 0 for AA123, 1 for BB987, 0 for CC000, 1 for DD999.

In order words, it should count 1 if there were >1 non duplicate values that that code.

 

How would you solve this?

 

Thanks!

Anonymous
Not applicable

So you want distinctcount only.

Try this
Measure= distinctcount(table[value])-1

Add id column and measure in table visual.

Thanks
Pravin
Anonymous
Not applicable

Hi PR20048119,

 

Thanks, your code solved the first part of the problem.

Sample_Measure_2 = DISTINCTCOUNT(Sheet1[Value])-1
 

Below is the screenshot for this.

2.JPG

 

At the same time, how can I add onto the above code, so that I can put this measure into a card? This card should show the value 2; BB987 counted once plus DD999 counted once.

 

Thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors