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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
EB09
Frequent Visitor

Measure counting distinct values with condition

Hi, 

 

I'm having trouble trying to create a new column in my table. 

 

I have several person ID's in the same table, but I only want to count it once for each FY (financial year). 

 

I need a formula that results in a '1' per row.  I hope the example below with my desired column explains what I need if anybody can please help.

 

Person ID       FY     (Desired Column)

1                   2024   1

1                   2024   0

2                   2024   1

2                   2024   0

2                   2024   0

1                   2023   1

1                   2023   0

1                   2023   0 

2                   2023   1

2                   2023   0 

2                   2023   0 

3                   2023   1

3                   2023   0

 

Appreciate any help!!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @EB09 

 

First you need to add the index column in the Power Query editor as shown below.

vxuxinyimsft_1-1702369593240.png

 

 

Then You can create a measure as follows.

 

 

 

result =
VAR _min =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        ALLEXCEPT ( 'Table', 'Table'[Person ID], 'Table'[FY] )
    )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Index] ) = _min, 1, 0 )

 

 

 

vxuxinyimsft_1-1702368822131.png

Is this the result you expect?

 

 

Best Regards,

Community Support Team _Yuliax

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
Anonymous
Not applicable

Hi @EB09 

 

First you need to add the index column in the Power Query editor as shown below.

vxuxinyimsft_1-1702369593240.png

 

 

Then You can create a measure as follows.

 

 

 

result =
VAR _min =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        ALLEXCEPT ( 'Table', 'Table'[Person ID], 'Table'[FY] )
    )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Index] ) = _min, 1, 0 )

 

 

 

vxuxinyimsft_1-1702368822131.png

Is this the result you expect?

 

 

Best Regards,

Community Support Team _Yuliax

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

EB09
Frequent Visitor

Sorry I'm a new user I'm not too sure, is there anyway this can be done from what I've said? Do I need to structure in a different way?

Fowmy
Super User
Super User

@EB09 

is there any other columns in this table that would identify the order or the sort. What differentiates each line when they are the same ID and the FY?

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.