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
Matt_P
Helper I
Helper I

Counting number of values excluding some repeats.

Hi  I am hoping someone can point me in the right direction...

 

A single 'data entry' can have multiple rows due to the different data points collected, consider the table below.

 

U1F1F2F3F4Q1Q2
abc1AA1234YS1R123
abc1AA1234YS1R223
sse1BB1235NS1R122
sse1BB1235NS2R122
asdfe2CC1234YS1R132
asdfe2CC1234YS3R132
asdfe2CC1234YS1R232
asdfe2CC1234YS3R232
dde34AA1234NS5R511

 

[U1] identifies the data entry
[F1] Identifies the subject
[F2], [Q1] & [Q2] will have the same value per [U1]/[F1] entry
[F3] and [F4] can have different values per [U1]/[F1] entry

 

Put another way, green values will not be different per [U1]/[F1] entry but red values can be.

I would like a count of [Q1] & [Q2] values for each [U1]/[F1] entry.

EG:

How many 2s in [Q1] for unique data entry
Answer is 2, 1 from abc1/AA1234 and 1 from sse1/BB1235

How many 2s in [Q2] for unique data entry
Answer is 2, 1 from sse1/BB1235 and 1 from asdfe2/CC1234

 

I would like a count of F3 and F4 values such that each unique combination of [U1]/[F1]/[F3]-[F4] value is counted.

EG:

How many S1s in [F3] for unique data entry
Answer is 3, 1 from abc1/AA1234, 1 from sse1/BB1235 and 1 from asdfe2/CC1234

How many R2s in [F4] for unique data entry
Answer is 2, 1 from abc1/AA1234 and 1 from asdfe2/CC1234

 

I have currently solved my counting problem by merging columns and counting unique values eg merging U1 and F3 and having a DistinctCount on the new column.  However, i'm looking for a more elegant solutiuon. I do need to catagorize (unpivot) [Q1] and [Q2] so I can use Q1 and Q2 as a ledgend in a graph but I suspect the extra rows will not impact on the counting solution.

 

Many thanks.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Matt_P , You can try measures like these two examples

 

countx(summarize(table, table[U1], table[F1], Table[Q1]),[Q1])

countx(summarize(filter(table, Table[Q1]=2), table[U1], table[F1], Table[Q1]),[Q1])

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Matt_P , You can try measures like these two examples

 

countx(summarize(table, table[U1], table[F1], Table[Q1]),[Q1])

countx(summarize(filter(table, Table[Q1]=2), table[U1], table[F1], Table[Q1]),[Q1])

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.