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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Wengel
Frequent Visitor

Only count a order the first time

Maybe there is an easy fix to this problem, that i just havent been able to figure out. 

 

I need to count order numbers on a specific date, but i only want to count the order number once, and it has to be the first time it appears. So if order number 213, have date 31/01/2022, and there is another entry on order number 213, on date 24/02/2022. I only want it to be counted the first time. 

 

Hope it make sense, and there is a fix to it 🙂 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I got myself reading documentation and found the solution! 


FIRST VALUE ACCEPTED =
CALCULATE(
MINX
( FILTER(Table, [Status] = "ACCEPTED"),Table[Date]),
ALLEXCEPT(Table,Table[Id])
)

 

     

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @Wengel ,

I created some data:

vyangliumsft_0-1660872621609.png

Here are the steps you can follow:

1. Create measure.

Flag =
IF(
    MAX('Table'[Date])=MINX(FILTER(ALL('Table'),'Table'[ID]=MAX('Table'[ID])),[Date]),1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1660872621612.png

3. Result:

vyangliumsft_2-1660872621619.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

Anonymous
Not applicable

Awesome solution! 

I got the same problem in here and this solutions tends to solve at least 85% of the situation..

But i have another doubt:

In this dax function created to find the min(value), is there anyway to get the min(value) that has another condition?

For example:

ID | Date | Status
1--|10/01| ERROR
2--|11/01| ACCEPTED
3--|13/01| ACCEPTED
4--|18/01| ERROR

If i apply the query itself, it will return me the ID 1, since it has the min value, but instead, i would like to get the ID 2, since it is the min value accepted..

This question makes any sense? Sorry for any inconvenience 😛 

Anonymous
Not applicable

I got myself reading documentation and found the solution! 


FIRST VALUE ACCEPTED =
CALCULATE(
MINX
( FILTER(Table, [Status] = "ACCEPTED"),Table[Date]),
ALLEXCEPT(Table,Table[Id])
)

 

     
johnt75
Super User
Super User

You could create a calculated column to store the first order date and then link that to your Date table instead of, or as well as, linking the existing order date column.

The new column could be something like

First order date = CALCULATE( MIN('Sales'[Order date]), ALLEXCEPT('Sales', 'Sales'[Order ID]) )

and your number of orders measure would be either a simple DISTINCTCOUNT or a DISTINCTCOUNT with USERELATIONSHIP if you have multiple relationships from Date to Sales.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.