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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ChiRomeu
Helper I
Helper I

Unique value on the table

Dear member,
 Please kindly help to calculate the unique value by the second column.

 

 

Best regards

Chi

Captura.PNG

1 ACCEPTED SOLUTION

Hi @ChiRomeu,

 

Yes it is possible. However, there should be another column to identify unique records since the values may repeat in your MasterCode Column.

 

I've taken UniqueColumn for the sake of this example:

 

Screenshot 2022-10-05 192859.jpg

 

Here is the DAX Formula that you can use to get the UniqueMaster:

 

UniqueMaster = IF(RANKX(FILTER('Table','Table'[MasterCode]=EARLIER('Table'[MasterCode])),'Table'[UniqueColumn],,ASC,DENSE)=1,1,0)

 

This formula will:

  1. Use the unique column to create ranks within the group of same values.
  2. Assign flag value 1 to the first rank from every group and 0 to all others.

 

Here's how the rank will be created:

 

Screenshot 2022-10-05 193635.jpg 

 

The DAX Formula mentioned above picks the first rank of every MasterCode. Note that for this to work, you must have a column with unique values.

 

Mark this post as a solution if that works for you!

View solution in original post

8 REPLIES 8
Shaurya
Memorable Member
Memorable Member

Hi @ChiRomeu,

 

Use this formula to create flag for unique values:

 

UniqueMaster = IF(SUMX('Table',IF('Table'[MasterCode]=EARLIER('Table'[MasterCode]),1,0))=1,1,0)

 

Screenshot 2022-10-04 040626.jpg

 

Works for you? Mark this post as a solution if it does! 

hi Shaurya,
 thank you for your idea, but there is a problem which is mastercode 1s should also has an 1 and others 0.

 Is it possible?

 

Best regards

Chi

Hi @ChiRomeu,

 

Yes, it is possible. You want the UniqueMaster to be 1 if the original value is either unique or the value itself is 1. You can just add an OR condition to check that and get the desired result. 

 

Use this DAX Formula:

 

UniqueMaster = IF(SUMX('Table',IF('Table'[MasterCode]=EARLIER('Table'[MasterCode]),1,0))=1 || 'Table'[MasterCode]=1,1,0)

 

Result:

 

Screenshot 2022-10-04 121114.jpg

 

Works for you? Mark this post as a solution if it does!

Hi Shaura,

 I would like to get like the picture.

Captura.PNG

Hi @ChiRomeu,

 

I get it now. You want the first occurence of any value to have flag 1 and others as 0. The value may or may not repeat. Is that right?

hi Shaurya,

 it is possible to get that?

 

Best regards

Chi

Hi @ChiRomeu,

 

Yes it is possible. However, there should be another column to identify unique records since the values may repeat in your MasterCode Column.

 

I've taken UniqueColumn for the sake of this example:

 

Screenshot 2022-10-05 192859.jpg

 

Here is the DAX Formula that you can use to get the UniqueMaster:

 

UniqueMaster = IF(RANKX(FILTER('Table','Table'[MasterCode]=EARLIER('Table'[MasterCode])),'Table'[UniqueColumn],,ASC,DENSE)=1,1,0)

 

This formula will:

  1. Use the unique column to create ranks within the group of same values.
  2. Assign flag value 1 to the first rank from every group and 0 to all others.

 

Here's how the rank will be created:

 

Screenshot 2022-10-05 193635.jpg 

 

The DAX Formula mentioned above picks the first rank of every MasterCode. Note that for this to work, you must have a column with unique values.

 

Mark this post as a solution if that works for you!

Correct

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.