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
snifer
Post Patron
Post Patron

count of id

i got a csv file with an id and transaction i need to count for each id how many transaction line there isCapture.PNG

in this case for id 8 should be 5

an easy task but i can find out right now im stuck

count row same id

8 REPLIES 8
vmakhija
Post Prodigy
Post Prodigy

@snifer

You can use something like this 

 

Column =
Var new = Table1[id]
Var Count1 = CALCULATE(
COUNTROWS(Table1),
all(Table1),
Table1[id] = new
)
Return Count1

@vmakhija

 

 

Column =
Var new = transactions[CustomerID]
Var Count1 = CALCULATE(
COUNTROWS(transactions),
all(transactions),
transactions[CustomerID] = new
)
Return Count1))

 

name of table column : transactions[CustomerID]

 

 I got an error

 

The syntax for ')' is incorrect. (DAX(Var new = transactions[CustomerID]Var Count1 = CALCULATE(COUNTROWS(transactions),all(transactions),transactions[CustomerID] = new)Return Count1)))).

 

 

@snifer

Please make sure you have correct opening and closing brackets in your column definition.

I created the column and got no errors 

 

Column =
Var new = Table1[ID]
Var Count1 = CALCULATE(
COUNTROWS(Table1),
all(Table1),
Table1[ID] = new
)
Return Count1

count =
Var new = transactions[CustomerID]
Var Count1 = CALCULATE(
COUNTROWS(transactions),
all(transactions),
transactions[CustomerID] = new
)
Return Count1

 

A single value for column 'CustomerID' in table 'transactions' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

@vmakhija

 

 

@snifer

 

are you creating it as column or measure?

The example I gave is for creating a column and not a measure.

@vmakhija

I tried both but same error

Hi @snifer,

 

That's weird. Can you share some snapshots?

Please also try this one. It's a calculated column.

 

Column =
CALCULATE (
    COUNT ( transactions[CustomerID] ),
    ALLEXCEPT ( transactions, transactions[CustomerID] )
)

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HotChilli
Super User
Super User

The simplest way would be to create a measure like this

Measure = COUNTROWS(Table1)

 

On the report canvas, drag the id field and this measure onto a table visualization

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.