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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors