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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply

Count the number of items per customer

Hi Team,

I am a bit confused. Could you help me please? 

I want to sum the number of items per order id. In my table, the order id shows multiple times as well as the item count. 
What I want to achieve is like:

Order_alpha_id                     Item count
zz999                                     8

Screenshot 2022-05-05 140703.png

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Andrew_na_lang,

 

I suggest you to create a measure to achieve your goal.

Sample:

RicoZhou_0-1652172460751.png

Measure:

M_Item_Count = 
CALCULATE(COUNTROWS('Table'))

Result is as below.

RicoZhou_1-1652172495616.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-rzhou-msft
Community Support
Community Support

Hi @Andrew_na_lang,

 

I suggest you to create a measure to achieve your goal.

Sample:

RicoZhou_0-1652172460751.png

Measure:

M_Item_Count = 
CALCULATE(COUNTROWS('Table'))

Result is as below.

RicoZhou_1-1652172495616.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PC2790
Community Champion
Community Champion

You can create a new table using DAX:

SUMMARIZE(<TableName>,[Order_alpha_id ], "CountbyOrderID",Count(order_id))

See if this gives you teh required result.

@PC2790 this sums the number of items per row. 

ZZ999 instead of 8 items only, gives me 64 instead.

That should not be possible,

Can you give me your data in copyable format?

No mate. It didn't work.

 

what error are you getting?

You can also try grouping the table in power Query

Transform Data--> Home -->Group by

filed name as alpha id and create a new column with operation as Count Rows and Column as your order id

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.