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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
filipe197
Frequent Visitor

Count distinct values of a column grouped by another column

Hello guys,

 

I need to calculate the client loading (distinct products) grouping it in the different profile segments. I did try first to create a measure like distinct number of products/distinct number of clients but obviously it is not enough because this has to calculate the distinct number of products by each client number and then summarize it before divide for the number of clients. Does any know hou to pull this off?? Example:foto pbi.JPG

 

 

 Like the example above,  the formula should be: Cliente Loading = number of products/mumber of clients an so then the results by profile segment are:

 

 

Profile SegmentClient Loading
Total13/5 = 2,6
Target6/3 = 2
Non Target7/2 = 3,5

 

Thanks in advance for the help.

1 ACCEPTED SOLUTION

Hi @filipe197,

 

Here are the formulas i wrote

 

Clients=CALCULATE(MIN(Data[Value]),Data[Attribute]<>"Current Price")

Products=DISTINCTCOUNT(Folha3[Product])

Client Loading=[Products]/[Clients]

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @filipe197,

 

If you share some sample data/pbix file, it will help for us to clarify your scenario and do some test.

How to Get Your Question Answered Quickly

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hello @v-shex-msft

 

I have replicated the example in a pbix file:

https://we.tl/PEILLkDdmX

 

It's all about solving what i shared in my first post, which i am not figuring out how to do so.

 

Thanks a lot,

Filipe

Hi @filipe197,

 

Here are the formulas i wrote

 

Clients=CALCULATE(MIN(Data[Value]),Data[Attribute]<>"Current Price")

Products=DISTINCTCOUNT(Folha3[Product])

Client Loading=[Products]/[Clients]

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello @Ashish_Mathur 

 

About your formula of Products, the ideia is to calculate the distinct products but by each client, so for target it should be 6 and for non-target it should bem 7. Let's see:
For the target we have client 123456789 which have 2 distinct products (A+B), client 125632444 which have 3 distinct products (A+B+C), and client 145320028 which have 1 distinct product (B). So the total distinct products of target by client is 2+3+1 = 6.
Can you do this?

 

Thanks,

filipe197

 

 

 

 

Hi,

 

The formula for Products should be:

 

=SUMX(SUMMARIZE(Folha3,Folha3[Client number],"ABCD",DISTINCTCOUNT(Folha3[Product])),[ABCD])

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.