cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Adding a new column to count the number of records

Hi,

 

Please consider following senario:

Data is:

 

NameDate
A01/09/2016
A02/09/2016
A03/09/2016
A04/09/2016
A05/09/2016
B01/09/2016
B01/09/2016
B02/09/2016
B02/09/2016
B02/09/2016
B03/09/2016
C05/09/2016
D02/09/2016
E03/09/2016
F04/09/2016
F04/09/2016

 

I want to add a new column to it to have the total number of rows per individual. I don't want measure, I want a column. With measure I know how to do it. my need is with column.

 

Desired output is:

 

NameDateCount
A01/09/20165
A02/09/20165
A03/09/20165
A04/09/20165
A05/09/20165
B01/09/20166
B01/09/20166
B02/09/20166
B02/09/20166
B02/09/20166
B03/09/20166
C05/09/20161
D02/09/20161
E03/09/20161
F04/09/20162
F04/09/20162

 

Please advise.

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sean Super Contributor
Super Contributor

Re: Adding a new column to count the number of records

an alternative to @KHorseman's solution above would be

 

Alt RowCount = CALCULATE ( COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[Name]) ) 

 

2016-09-29 - Alt RowCount.png 

View solution in original post

3 REPLIES 3
Highlighted
KHorseman Super Contributor
Super Contributor

Re: Adding a new column to count the number of records

RowCount = CALCULATE(
	COUNTROWS(TableName),
	FILTER(
		ALL(TableName),
		TableName[Name] = EARLIER(TableName[Name])
	)
)

Did I answer your question? Please mark it as a solution.

Proud to be a Datanaut!
Sean Super Contributor
Super Contributor

Re: Adding a new column to count the number of records

an alternative to @KHorseman's solution above would be

 

Alt RowCount = CALCULATE ( COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[Name]) ) 

 

2016-09-29 - Alt RowCount.png 

View solution in original post

KHorseman Super Contributor
Super Contributor

Re: Adding a new column to count the number of records

Oh yeah, that works too. I've had to do this in a few of my reports recently, but it usually has some other complicated conditions that made the ALLEXCEPT method much messier to write, so I sort of forgot it was an option.


Did I answer your question? Please mark it as a solution.

Proud to be a Datanaut!

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 442 members 4,046 guests
Please welcome our newest community members: