Forum Discussion

BalAW's avatar
BalAW
New Member
10 years ago
Solved

Using two fields to create a combination key

Hi,   I am in need of advice on whethe rit is possible to create a combination of two fields to give me unique values.   For example i have a transactional database:   ID                       ...
  • ankitpatira's avatar
    10 years ago

    BalAW looking at your dataset even combination of ID and DATE doesn't make it unique for example ID = 1 and DATE = 1/1/16 is twice. What you need is something called Composite Primary Key which is a primary key created using more than one column. You need to create that at data source level and import it into power bi and use that against N_AMT field. That would be the best approach.

     

    Other way you can do is to declare N_AMT field as Data Type of Text in Power BI but that means you will only be able to use it in few visuals such as Table or Matrix since in other values you need Data Type of Number to drop into Values section. 

     

    My suggestion is to create primary key of combination at data source level and import into power bi or you can also use DAX in power bi to create something unique to say combination of ID + DATE + Incremental number from 1 till end of rows so that each rows has unique value.