cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
anni Frequent Visitor
Frequent Visitor

How to get distinct count in a pivot-like way

Hi all,

 

I'm searching for an answer as I cannot find exact case.. 

 

I have a several tables. One on them contains data about users and other - data about products they buy (X is the biggest product and others are like 55 different ones). 

 

TABLE 1                 different table:          TABLE 2

Products                                                 Users

Product X                                                Company 1

Other product 1                                      Company 2

Other product 2                                      Company 3

Other product 3                                      Company 4

Other product 4                                      Company 5

 

I need to create a table where I show how many distinct users are using 

1) Product X 

2) Any other than product X
3) Product X and 1 other product 

4) Product X and 2 other products

5) Product X and 3 other products

6) Product X and 4 or more other products

result:

Month   Product x            Not using Product X     Product x +1     Product x +2    Product x+3    PRoduct x +=>4
JAN          distinct count       ....                                 ....                        ....                       ....                         .... 

FEB           distinct count          ....                             ...                            ....                     ....                         ....

MAR        ....                                ...                              ....                         ....                     ....                        ....


How can I create this? I know how to do it in excel, but in power bi I cannot create the logic so it looks like a table I could split by months after. 

Please help as this is making my mind blow up! 

3 REPLIES 3
Community Support Team
Community Support Team

Re: How to get distinct count in a pivot-like way

Hi @anni ,

 

I create a sample you can reference to modify yours.

 

  1. These are my two tables.

1.png

 

  1. Create a measure and add it into a matrix.
Measure = CALCULATE(DISTINCTCOUNT(Table2[Users]),ALLEXCEPT(Table2,Table2[Date].[Month],Table2[Products]))

2.png3.jpg4.png

Best Regards,

Xue Ding

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

Community Support Team
Community Support Team

Re: How to get distinct count in a pivot-like way

Hi @anni ,

Could you tell me if your problem has been solved? If it is, kindly mark the helpful answer as a solution if you feel that makes sense. Welcome to share your own solution. More people will benefit from here.

 

Best Regards,

Xue Ding

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

anni Frequent Visitor
Frequent Visitor

Re: How to get distinct count in a pivot-like way

Hi, 

 

It actually did not help. 

 

I was trying to describe my issue in a very simple way but actually there is some level of granularity that I did not picture here and that makes it more complicated. 

IT looks more like this:

TABLE 1                 different table:          TABLE 2

Products                                                 Company                Resellers      Users

Product X                                                Company 1            Reseller A     Random 

Other product 1                                      Company 2            Reseller B     Common

Other product 2                                      Company 3            Reseller C     Else

Other product 3                                      Company 2            Reseller D     Different

Other product 4                                      Company 1            Reseller E      Unknown 

 

So create an overview to see which user under each reseller under what Company - this is what im still struggling with. But thanks for the help effort!

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.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 6 members 1,297 guests
Please welcome our newest community members: