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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mcgeeks
Helper I
Helper I

Please help with counting a very tricky one

Greetings,

 

  • I am tasked with counting 2 columns, Sample and Test, with millions of rows. 
  • Items in both columns can be repeated and typically are. 
  • I already gather a distinct count of the Sample column, so that's fine. 
  • So now, I'm trying to gather how many test names are in the test column per sample in the sample column.  If I pull distinct values from the test column it's only 11 tests.  If I pull non-distinct values I get many more than I should. 

 

Then comes the really tricky part.  The Tests can all be ran individually.   However, sometimes Test 1, Test 2, and Test 3 need to be tied together for a sample and need to be counted as 1 Test.  I've tried grouping "Tests" in PowerBI to achieve that, but that doesn't seem to help.

 

Any ideas anyone?  Thanks in advance.

 

Please see the example below.

 

SampleTest 
ATEST 1Sample A=2 test names
ATEST 1 
ATEST 1 
ATEST 2 
ATEST 2 
BTest 1Sample B=3 test  names
BTest 2 
BTest 3 
CTEST 1Sample C=2 test names
CTEST 2(1,2,3 as 1)
CTEST 3 
CTest 1 
CTest 1 
CTest 1 
CTest 1 

 

  
4 REPLIES 4
Anonymous
Not applicable

Hi, @mcgeeks 

According to your description, if the Test columns are different and the Sample columns have the same data, then the corresponding rows are output, there are a few questions:
1.Sample C=2 test names how do you get this data, (1,2,3 as 1) means if TEST 1, TEST 2, TEST 3 all appear then it is only seen as TEST 1?
2. you eventually want to realize the effect in the matrix, you can share the effect you want to realize as a snapshot.

 

Best Regards,
Yang
Community Support Team

 

Hi Yang, thanks for responding. 

 

Our tests are such that sometimes you need test 1.  And at other times you need a separate test 2 or test 3.  But for some you need a combination of tests, in my example that was a combo of test 1, test 2, and test 3, and they want it counted as one test.

 

Let me give you an actual detailed example.  I'm posting a picture of the actual data as it comes from a huge database, it's hard to extract just that.  In this example the "sample" is a string of numbers on the left.  Then the next column is a distinct count of the sample and totals correctly.  Then the Count of Test Groups is a distinct count of test names (a text column) that gives the correct total of tests per sample (meaning per row) but does not add them up correctly for the total at the bottom. 

 

The TestCount column is one where I was trying to achieve that total with a combination of two measures.  Which is not achieving what I'm after.  It instead is just mimicking what I'm seeing in the Count of Test Groups column.  Here are those two measures:

 

CountTests = DISTINCTCOUNT('ASG Data'[Test])
TestCount = ifISFILTERED('ASG Data'[Sample]), [CountTests], SUMX(values('ASG Data'[Sample]), [CountTests]))
 

mcgeeks_0-1710339333876.png

I only need 2 columns with correct totals.  Count of samples which is already correct, and a test count with whichever column name.  I'm just having problems getting the total correct on that column with a distinct count of text test names per sample.

 

Here is a snapshot of the list without a sample expanded.

mcgeeks_1-1710340264397.png

The count of sample is totaled correctly.  Either the Count of test groups column or the TestCount column TOTAL needs to read 90.

 11
 11
 11
 11
 12
 11
 11
 11
 11
 12
 12
 11
 13
 18
 17
 17
 17
 17
 17
 17
 17
 17
 18
Total2390

 

I know this was lengthy, but hopefully I've given enough information to explain the issue.  Thank you for your assistance on the matter.

 

Regards,

mcgeeks

mcgeeks
Helper I
Helper I

So I made progress. 

  • I created a grouping for some tests. 
  • I then put the grouping in the matrix visual. 
  • It counts the ROWS correctly, and shows the test names on rows correctly, but shows the total at the bottom of the matrix for tests incorrectly. 
  • I used a distinct count in the visual for that column to get the right count of tests per sample, but the total is garbage.  It's not summing a total of the column's test count, which is a count of text test names per row as one would expect.  It's a distinct count of the various names, and as such only ever goes up to the total number of tests ran on samples for that visual.  It will go up to 11 max per row (per sample).

If I can now get a sum of the count of test groups  in that matrix I'll be good.

  

mcgeeks
Helper I
Helper I

Follow up: I have the data in a matrix table.  A distinct count of sample works.  A non-distinct value for Test gives me way too many in the count.  We think due to the tests that should be grouped together in the count.  I was hoping that grouping the Tests could help but it doesn't seem to change the count at all.

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.