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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
humphra2
New Member

M Equivalent to LOOKUPVALUE (trying to find first unique value)

Hi. 

 

I'm completely new to Power BI and am trying to work out what the M equivalent to the following DAX formula would be.

 

Unique ThirdParty_Ref = IF(GE_Data[ThirdParty_Ref]<>LOOKUPVALUE(GE_Data[ThirdParty_Ref],GE_Data[Index],GE_Data[Index]-1),1,0)

 

I am trying to indicate if a value in a particular column is the first unique/distinct instance of that value. If yes, return a value of 1. If not, return a value of 0

 

Thankyou!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @humphra2 ,

You can add a custom column and with function.invoke to looping on the current table and based on index and compare with its result:

#"Added Custom" = Table.AddColumn(#"previous step", "Custom", each if [Index]<>0 then if [ThirdParty_Ref] <> Function.Invoke((_index as number)=> Table.SelectRows(#"previous step",each [Index] = _index-1)[ThirdParty_Ref]{0},{[Index]}) then 1 else 0 else null )

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @humphra2 ,

You can add a custom column and with function.invoke to looping on the current table and based on index and compare with its result:

#"Added Custom" = Table.AddColumn(#"previous step", "Custom", each if [Index]<>0 then if [ThirdParty_Ref] <> Function.Invoke((_index as number)=> Table.SelectRows(#"previous step",each [Index] = _index-1)[ThirdParty_Ref]{0},{[Index]}) then 1 else 0 else null )

Regards,

Xiaoxin Sheng

MFelix
Super User
Super User

Hi  @humphra2 ,

 

The best person to answer you this questions is @ImkeF  she's the one to go or M language questions.

 

@ImkeF , can you please assist on this question for sure you will make it very easily.

 

Regards

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.