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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
UncleLewis
Helper V
Helper V

Create Unique Index Of Two Fields Yields Duplicates

Hi,

I have data from a survey.
The survey has ~350 questions..

There are variable number of responses to choose from based on the question.

One question is which state do you work so there are 52 possible responses (Territories)

I created an index for the questions and a separate index for the responses.

The responses re-seed at 1 for every new question.

 

I tried to concatenate the question index with the response index so for the state question, this gave me complete Index values

2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8. 2.9 2.10, ...

I then converted the data type to decimal and now I have duplicates at 2.1, 2.2, 2.3, 2.4, and 2.5

 

How can I create a unique non-repeating index in this case?

 

Thanks,

-w

1 ACCEPTED SOLUTION

Thanks Tom,

I ended up mutiplying by 0.01 for all values less than 10.
I think this pattern will work for all combinations of Questions/Answers, not just this case where there are 52 possible responses.

Thanks,
-w

if
[PK] < 10
then
Number.ToText( [Group] + ( 0.01 * [PK]))
else
Number.ToText([Group]) & "." & Number.ToText([PK])

 

index.png

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey @UncleLewis ,

I recommend this article: https://www.daxpatterns.com/survey/

Maybe you have to check your ToDecimal conversion, as "2.4" and "2.40" will be converted to the same decimal number:2.4. I would suggest that you convert the answers to a fraction, meaning "2.4" will become "2.04" and "2.40" will become 2.4.

Hopefully, this provides you with an ideas of how to tackle your challenge.

Regards,
Tom






Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks Tom,

I ended up mutiplying by 0.01 for all values less than 10.
I think this pattern will work for all combinations of Questions/Answers, not just this case where there are 52 possible responses.

Thanks,
-w

if
[PK] < 10
then
Number.ToText( [Group] + ( 0.01 * [PK]))
else
Number.ToText([Group]) & "." & Number.ToText([PK])

 

index.png

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.