Forum Discussion
Adding conditional unique index column based on several criterias
- 9 years agoThank you so much, looks very useful. I will try to implement this and get back with feedback as soon as possible. Thanks again!
M or DAX is going to depend, can you post some sample data and an idea of your various tables involved? Not even sure what your unique index column is, is it just a unique integer number?
Hi, thanks for yor quick reply!
Sure, here is a little sample. The first four columns are currently provided and will receive new records when updated, and what I need is an additional column that, by checking for customer number or email, or name and phone, provides the ID that already exists, or creates a new unique interger number:
| Customer Number | Customer name | Phone | ID | |
| 10135000 | [email protected] | Benny Johnson | 4329463662 | 1 |
| 10031030 | [email protected] | Pete Madsen | 4346123746 | 2 |
| 10056030 | [email protected] | Pete Madsen | 4346123746 | 2 |
| 10164001 | [email protected] | Donna D. Nielsen | 4346272296 | 3 |
| 10258006 | [email protected] | Sanny Peterson | 4346414642 | 4 |
| 10258032 | [email protected] | Sanny Peterson | 4346414642 | 4 |
Hope that clarifies it, otherwise please let me know!
Thanks again,
Marianne
- Anonymous9 years agoNot applicable
Hi MarianneElver,
You can write a custom function to call the hash generate api, then input these condition columns to generate the unique code.
Regards,
Xiaoxin Sheng
- MarianneElver9 years agoHelper IIIHi Xiaoxin, Thanks for the idea, unfortunately writing a function is a little ahead of my current capabilities where I'm having trouble finding the right M-code or DAX to figure it out how to come along this challenge! But thanks anyway, Marianne
- ImkeF9 years agoCommunity Champion
Hi Marianne,
if my understanding of your request is correct, then PowerBI isn't the right tool for it:
You're importing data in Power BI and want to create a value that sticks to the imported data, also when the next refresh is done?
Problem is, that there is currently no concept for storing such data in PBI. So you would need to export your new table with the newly generated ID's in order for them to be kept ... & reimported & merged with the new data (2nd run), where again new rows with empty ID's will come in.