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

count of distinct values across multiple columns with in the same table.

I have a table with sales and multiple owners (owner 1, owner 2, owner 3) the goal is to create a measure that calculates the average sales per owner. so the eqaution is sales / count of owners.

what i am having difficulty with is getting the count of owners. the business need is to only have distinct values from all 3 columns. From a querying perspective, it would be to union the three columns together and keep the distinct values. however i am having trouble getting the same result with a dax equation. 

I have been trying code similar to this:

count = 

UNION(VALUES(table[owner 1]),VALUES(table[owner 2]),VALUES(table[owner 3]))
 
however i always seem to get this error:
Calculation error in measure 'CRM_EA_Data'[Count]: A table of multiple values was supplied where a single value was expected.
2 REPLIES 2
Community Support Team
Community Support Team

Re: count of distinct values across multiple columns with in the same table.

Hi @buffanut ,

 

You may unpivot the three owner columns into a separate column. Enter into Query Editor, click on columns owner 1, owner 2 and owner 3 at the same time, then choose "Unpivot Columns" option, you can rename this result column "Attribute" with "owner " . Don't forget to click the "Close & Apply" button. Then you can get count of owners using code DISTINCTCOUNT([owner]) .

 

59.png

 

Best Regards,

Amy

 

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

 

buffanut Regular Visitor
Regular Visitor

Re: count of distinct values across multiple columns with in the same table.

@v-xicai 

I'm DIrect Querying into a database and such transformations, unfortuantly are not allowed. This is why i needed a dax equation. We're working around however and bringing in a serperate reference table. 

-thank you. 

 

Helpful resources

Announcements
Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

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

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 124 members 1,682 guests