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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
avioti
Frequent Visitor

DAX SUM/distinct(Count)

Hello Guys

Could you help me pls?

 

I have a table called sales and has column with total sales and another collumn code_sales. I would like to sum (total sales) and divide by the quantity of code_sales, however, I would like to count the unique code sales. Would it be possible to use sum + count distinct?

 

 

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Yes.  You could do it all within:

 

Your Measure = DIVIDE(
    SUM('Sales'[Total_Sales]),
    DISTINCTCOUNT('Sales'[Code_Sales])
)

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Yes.  You could do it all within:

 

Your Measure = DIVIDE(
    SUM('Sales'[Total_Sales]),
    DISTINCTCOUNT('Sales'[Code_Sales])
)

Thanks for the response. It works fine.

 

Now i have another situation. How to show distinct values in a new column into my table?

Like below

 

For example:

 

Code Sales  Distinct

1000               1

1000               0

2000               1

3000               1

4000               1

4000               0

Anonymous
Not applicable

This can be done with a simple Matrix visual.  Put 'Code Sales' as your rows and also again into the values.  Select the dropdown for the values version and choose "Count (Distinct)"

I understand, but i would like to have this info in a table. Is it possible?

Anonymous
Not applicable

Easy (but not the most optimal):
Start in Power Query (Edit query button).  Make a new query and have the Source line be:

Source = #"Sales"

Now delete all other columns except for [Code_Sales]

Now remove duplicates

Now sort.

Close & Apply.
Link this new table with the Sales table

Create a new column and have it be:

My Distinct = [Your Measure]

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.