cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PeterL1 Regular Visitor
Regular Visitor

Sum & Count of DistinctCount depending on Groups

Hi, 

 

There is probably a question for this, but cannot find one.

I need PowerBi to calculate a sum of total transaction, as well as a count for transactions within a grouped product group.

 

I've got the following data (i've done group for the product groups):

 

 

TransactionIDProductProduct GroupGROUP (NOT IN DATA)
1large bikeLARGE BIKESBIKES
1small bikeSMALL BIKESBIKES
1hardcover bookHARDCOVER BOOKSBOOKS
1paperback bookPAPERBACK BOOKSBOOKS
1platePLATESCROCKERY
2bowlBOWLSCROCKERY
3platePLATESCROCKERY
3hardcover bookHARDCOVER BOOKSBOOKS
4bikeBIKESBIKES
4large bikeLARGE BIKESBIKES
4small bikeSMALL BIKESBIKES
4hardcover bookHARDCOVER BOOKSBOOKS

 

What i have done is to concatenate the TransactionID and the Product Group (PRODTRANSID), and done a measure =DISTINCTCOUNT (data1[PRODTRANSID]) which will give me the counted transactions for each product group. (dont know if this is correct but shows the right numbers)

 

 

What i cant figure out is how to make it look like the below results (depending on how many transactions are done in each product group.

I want a transaction to be 1 if you have sold a large bike and a small bike in the same transaction.

i've tried =CALCULATE(DISTINCTCOUNT(data1[PRODTRANSID]),data1[GROUP (NOT IN DATA)]) but just sums up the transactions.

 

GROUPAll Product Groups (SUM)Transaction Count By Product Group
BIKES42
BOOKS43
CROCKERY43
PLANT41

 

Note that i have over 60 million lines of data and i have more than 200 product groups.

 

Thanks 
Peter

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Sum & Count of DistinctCount depending on Groups

Why not just use simple DISTINCTCOUNTs?

 

All Product Groups (SUM) = DISTINCTCOUNT(data1[Product Group])

Transaction Count By Product Group = DISTINCTCOUNT(data1[TransactionID])

If you then put a table with GROUP (NOT IN DATA) column (renamed to GROUP) and two measures shown above for the data you provided the result would be like:

 

groupresult.pngSample result

Note: you may want to hide Total row as it also calculates distinct counts of groups and transactions.

 

Hope that helps.

 

Cheers,

Pawel

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Re: Sum & Count of DistinctCount depending on Groups

Why not just use simple DISTINCTCOUNTs?

 

All Product Groups (SUM) = DISTINCTCOUNT(data1[Product Group])

Transaction Count By Product Group = DISTINCTCOUNT(data1[TransactionID])

If you then put a table with GROUP (NOT IN DATA) column (renamed to GROUP) and two measures shown above for the data you provided the result would be like:

 

groupresult.pngSample result

Note: you may want to hide Total row as it also calculates distinct counts of groups and transactions.

 

Hope that helps.

 

Cheers,

Pawel

View solution in original post

Helpful resources

Announcements
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.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 150 members 1,849 guests
Please welcome our newest community members: