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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
croberts21
Continued Contributor
Continued Contributor

How to count records in a table?

I have Free PBI Desktop v2.105 (64 bit free version May 2022) on 64-bit Windows Server 2019 Datacenter v1809. 

I have a table with several columns in it, here are the column names and data type in parenthesis: Invoice date (date), Job Num (text), Customer name (text), Job Desc (text), and Invoice Amount (decimal). A slicer chooses the sales person and only shows data for that sales person. The Invoice Amount column gives me a total of all invoices at the bottom of the table which is what I want. But I'd also like to count the number of records shown at the bottom of the table, like how PBI shows the total Invoice Amount. Is that possible? 

I have selected the table viz, and in the fields buckets I right click Job Num, and select Count but that changes the actual job in every row to a "1" which is not what I want.

An alternative is to use a Card viz to count the records. There are 23 records for sales person A but my card, set to count the Job num, shows 252,000 jobs, which is all of them in the Jobs table. Why doesn't the card only count the records in the table viz?

Thank you for your time! 

 

Example output:

 

Invoice Date | Job num | Customer Name | Invoice Amt

1/21/22        | 1000       | Smith Industries | 1000.00

1/23/22        | 1001       | K&K                    | 2500.00

1/25/22        | 1002       | Smith Industries | 1000.00

2/1/222        | 1000       | Smith Industries | 50.00

Total             |                |  4                        | 4550.00

 

 

8 REPLIES 8
PC2790
Community Champion
Community Champion

Hello,

I tried to visualise your data and created a table:

Invoice date Job Num  Customer name Job Desc  Invoice Amount
1-Jul-22 1 A Sales 230
15-Jul-22 2 B Marketing 400
12-Jul-22 3 A IT 100
15-Jul-22 1 B Sales 1000
30-Jul-22 4 A Marketing 200

 

And then as per your requirement tried to create some visuals:

No selection onslicer

PC2790_1-1659440789374.png

 

 

 

B selected on slicer:

PC2790_0-1659440773842.png

Is that what you are after?

If yes, attached is the reference file for you.

If no, please further explain your requirement

croberts21
Continued Contributor
Continued Contributor

Sort of. I would like, at the bottom of the table, the Count of Customer Name, without the Count Customer Name column. 

 

I am unable to do HTML tables here so I will try to make a simple table here. 

 

Invoice Date | Job num | Customer Name | Invoice Amt

1/21/22        | 1000       | Smith Industries | 1000.00

1/23/22        | 1001       | K&K                    | 2500.00

Total             |               |  2                         | 3500.00

 

See if this helps:

_Measure = 
var _count = COUNTROWS ( InvoiceTable )
return
    IF (
        HASONEVALUE ( InvoiceTable[Customer name] ),
        SELECTEDVALUE ( InvoiceTable[Customer name] ),
        _count
    )

PC2790_0-1659450764573.png

 

Greg_Deckler
Community Champion
Community Champion

@croberts21 You could do this by using the technique found in Measure Total The Final Word. Essentially return the Job Number for the rows in your table but in the total line, return the number of records for the table visualization. This Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you. I'm not sure I understand though. The link you provided is about summing numbers. I want to count Job Num and put that count at bottom of the Job Num column. 

@croberts21 Right, instead of summing you would use COUNTROWS across your SUMMARIZE.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I don't want another column shown in the table to count the rows, as every value would be 1, then that 1 would be summed for every row. The Powers What Is would like just a count of Customer Name. Here's what I added in another reply.

 

Invoice Date | Job num | Customer Name | Invoice Amt

1/21/22        | 1000       | Smith Industries | 1000.00

1/23/22        | 1001       | K&K                    | 2500.00

1/25/22        | 1002       | Smith Industries | 1000.00

Total             |                |  3                        | 4500.00

 

Under Customer Name is the total count of customer names (not distinct as Customer Names could repeat). The count could also be under Job num, it doesn't have to be under Customer Name. Job num could be duplicated as we might have multiple invoices for that job. 

@croberts21 Again, that is the trick that Measure Totals, The Final Word solves. You create a measure like this:

 

Job number = MAX('Table'[Job num])

 

This returns the job number for an individual row. Then you create another measure that you actually use in your visualization like this:

 

Job number total = IF(ISINSCOPE('Table'[Job num]), [Job number], COUNTROWS(SUMMARIZE('Table',[Invoice Date], [Job num], [Customer Name]))

 

Something along those lines.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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