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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
djdubbert
New Member

First Occurrence of a Value

I want to create a new column with a 1 when the 1st occurence of the 'Occurrences UID' column happens, and the new column to have a 0 for all other instances. In excel the formula is: =IF(COUNTIF($AO$2:AO2,AO2)>1,0,1). How could I accomplish this in Power BI? 

 

djdubbert_0-1626359953720.png

 

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

How do you decide which is the first?  ie how is the list sorted?

In this example I'm sorting by a column called amt.  You can change that for however you want to sort it.  RANKX also has extra parameters for ordering ascending or descending if you need it.

 

First =
VAR _Current = 'Table'[Occurences UID]
VAR _Rank =
RANKX(
FILTER('Table',
'Table'[Occurences UID] = _Current
),
'Table'[amt]
)
VAR _Result = IF(_Rank = 1, 1, 0)
RETURN
_Result

View solution in original post

2 REPLIES 2
djdubbert
New Member

This worked! Thank you for your help!

PaulOlding
Solution Sage
Solution Sage

How do you decide which is the first?  ie how is the list sorted?

In this example I'm sorting by a column called amt.  You can change that for however you want to sort it.  RANKX also has extra parameters for ordering ascending or descending if you need it.

 

First =
VAR _Current = 'Table'[Occurences UID]
VAR _Rank =
RANKX(
FILTER('Table',
'Table'[Occurences UID] = _Current
),
'Table'[amt]
)
VAR _Result = IF(_Rank = 1, 1, 0)
RETURN
_Result

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.