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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

How to count distinct order numbers without losing data

Hi everyone!

 

I have read a lot of other posts but I can not solve the problem I'm currently facing.

At the moment, I have multiple tables in my dataset imported in powerBI.

One of which displays all received orders, including: 1. Order number, 2. Order status (1;2;3;4), 3. Order date, 4. Sales area, 5. Product etc. 

Here is an easy version of the dataset:

Screenshot 2020-03-18 at 18.08.19.png

It can be the case that an order includes multiple products. 

In that case, multiple rows are created which start with the same order number. 

Also, when an order is changed, it will create another row.

 

My goal is to create a table like this (there are not 6 orders, but only 3 distinct orders):

Screenshot 2020-03-18 at 18.07.24.png

I'm looking for a DAX function which can enable me to count the distinct number of (last placed) orders, without deleting information from the table (as in another table, I want to still be able to see that Sweden ordered bread, eggs & cheese (not just Cheese).

Therefore, I don't think the power query function of 'delete dublicated rows' works for my problem. 

I have tried both the DISTINCT and COUNTDISTINCT functions, but I'm only getting errors or the total sum of orders (in the picture example, the total distinct orders would be 3).

This, however, doesn't enable me to spread the data over areas. 

 

I was thinking perhaps a solution exists by creating another column, which can display "1" when an order number is only present once (order 2 in the picture), or when it was entered last (if the order number is more common, like order 1 & 3 in the picture), and else "0". 

 

I'm looking forward to your advice!

 

Jeffrey 

1 ACCEPTED SOLUTION
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

You can change to:

 

image.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Can you post that sample data as text?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
ChrisMendoza
Resident Rockstar
Resident Rockstar

@Anonymous -

You can change to:

 

image.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable

Thank you @ChrisMendoza

 

Sorry, completely forgot this was possible too, I was thinking way too difficult.

Solved my problem!

amitchandak
Super User
Super User

you tried distinctcount or countdistinct ?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.