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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
bdeleur
Helper III
Helper III

Unique value count only at start date

Hi,

 

I have a datebase and I need to count only the first row of the unique reference.

 

So it looks like this:

ReferenceStart date
11-1-2023 17:00
21-1-2023 16:23
112-1-2023 10:34

 

The expected result is:

1-1-2023 2 (reference 1 and 2) and specified at hour: 1 at 16:00 (reference 2) en 17:00 1 (reference 1)

and no count for reference 1 on 12-1-2023

 

I can get the count when the reference is present but I only wants the first and ignore the rest.

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @bdeleur 

 

You can try the following methods.

Column = 
Var _count= CALCULATE(COUNT('Table'[Reference]),ALLEXCEPT('Table','Table'[Start date]))
Var _mindate=CALCULATE(MIN('Table'[Start date]),ALLEXCEPT('Table','Table'[Reference]))
Return
IF([Start date]=_mindate,_count,BLANK())

vzhangti_0-1682493868362.png

vzhangti_1-1682493895049.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @bdeleur 

 

You can try the following methods.

Column = 
Var _count= CALCULATE(COUNT('Table'[Reference]),ALLEXCEPT('Table','Table'[Start date]))
Var _mindate=CALCULATE(MIN('Table'[Start date]),ALLEXCEPT('Table','Table'[Reference]))
Return
IF([Start date]=_mindate,_count,BLANK())

vzhangti_0-1682493868362.png

vzhangti_1-1682493895049.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Hi @v-zhangti,

 

Tnx for you answer.

When I apply the code at my database I think it is almost correct. When I use a filter on the column with 1 I get the first but sometimes I see a different number (2 till 6). When I filter on the reference that is the only result.

I think that I get the result I want when I filter out the blank results but why generates the higher numbers?

I'll validate a bit more to see what exactly is happening.

 

Edit: I get it now. On the exact date and time there a 3 results in the database. It generates a 3 because it's number 3 of the reference numbers. But that is okay and no problem.

I'll do the validating but it seems alright. I'll mark your answer as the solution!

Tnx!!

bdeleur
Helper III
Helper III

Anybody an suggestion?

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors