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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Using ALLSELECTED and DISTINCTCOUNT

Hello Power BI Community!

 

I was wondering if anyone can help with a DAX.

 

I have a table with different clients and personel (from different locations) and I want to obtain an ALLSELECTED total but only counting DISTINCT clients. The table looks like this:

 

USER |   CLIENT NAME           | LOCATION
   1          RONALD W                    A
   2          RONALD W                    A
   2          RONALD W                    A
   3          RONALD W                    A
   3          RONALD W                    A
   6          STACY L                          A
   7          JHON C                          B
   8          GENERIC CLIENT1          B
   9          GENERIC CLIENT2          B
  10         GENERIC CLIENT3          C

 

Basically, the result Im looking for is the total of distinct clients (6) per segment and this total to repeat for every user per location. So I can calculate the number of unique clientes attended by every personel divided by the total amount of distinct clientes that
have been attended.

I tried something like this but I haven't been able to integrate the distinctcount function (is it even possible?) to this ALLSELECTED:

CALCULATE(COUNTROWS(ALLSELECTED(Table1;ClientNamesColum));table1[segment] IN {"Segment A"})
 
However, this formula only gives me the total amount of clientes attended, not the TOTAL DISTINCT AMOUNT of Clientes. Appreciate the help in advance.

OGB.
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Calculate the number of unique clientes attended by every personel divided by the total amount of distinct clientes that
have been attended.

Here are the steps you can follow:

1. Create measure.

measure1 =
CALCULATE(DISTINCTCOUNT('Table'[Client Name]),FILTER(ALLSELECTED('Table'),'Table'[Location]=MAX('Table'[Location])))
measure1 =
CALCULATE(DISTINCTCOUNT('Table'[Client Name]),FILTER(ALLSELECTED('Table'),'Table'[Location]=MAX('Table'[Location])))
divide =
DIVIDE([measure1],[measure2])

2. Result:

vyangliumsft_0-1627546741734.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Calculate the number of unique clientes attended by every personel divided by the total amount of distinct clientes that
have been attended.

Here are the steps you can follow:

1. Create measure.

measure1 =
CALCULATE(DISTINCTCOUNT('Table'[Client Name]),FILTER(ALLSELECTED('Table'),'Table'[Location]=MAX('Table'[Location])))
measure1 =
CALCULATE(DISTINCTCOUNT('Table'[Client Name]),FILTER(ALLSELECTED('Table'),'Table'[Location]=MAX('Table'[Location])))
divide =
DIVIDE([measure1],[measure2])

2. Result:

vyangliumsft_0-1627546741734.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Anonymous , Try like

CALCULATE(DistinctCOUNT(Table[CLIENT NAME]), filter(ALLSELECTED(Table1),table[segment] IN {"Segment A"}))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.