Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Dimension with no unique key

i have a dimension without a unique key.

say for example, in Customer dimension, one customer can belong to many REP’s in same State.

how can I join this dimension with my Transactions fact table?

Ex Customer Table:

Customer1,State1,REP1

Customer1,State1,REP2

Customer1,State1,REP3…..

so, any ideas to generate a unique key in this scenario?

11 Replies
sushil353
Honored Contributor II

Re: Dimension with no unique key

Hi,

Can u provide structure for your FACT's and DIMENTIONS

HTH

Sushil

whiteline
Honored Contributor II

Re: Dimension with no unique key

Hi.

You could use AutonumberHash256 function to generate unique id:

AutonumberHash256(Customer, REP) as IDCustomerREP

Not applicable

Re: Dimension with no unique key

Hi Sushil & Whiteline,

i think, i didn't explain the scenario properly.

I do have Customer & State fields in sales fact table.

i need to connect this Sales table to Customer dimension by depending on those fields.

Thanks for your help.

Re: Dimension with no unique key

HI

What are the fields in sales table??

Not applicable

Re: Dimension with no unique key

Hi ramasamy,

Sales:

SO No,Customer, State,Revenue.

Customer:

Customer,State,Rep.

Thanks for ur reply.

Re: Dimension with no unique key

Hi

Then customer is common field to each other. so they automatically combine with each other but change the state field name as saleState. Otherwise, it form loop or synthetic key..

or

Try like this

Load customer&''&State as Key,customer as salesCutomer, state as salesState, revenue,soNo from sales;

Load customer&state as Key,state, customer ,rep from customertable where exists(Key,Key);

//by this,second table load only if key exists in the first table only..

see this link:

http://www.quickqlearqool.nl/?p=910

for join.

Hope it helps

Not applicable

Re: Dimension with no unique key

but the problem is customer&state as Key is not a unique key in Customer dimension.

one customer can have many rep's for same state.

Ex Customer Table:

Customer1,State1,REP1

Customer1,State1,REP2

Customer1,State1,REP3…..

Re: Dimension with no unique key

Hi

then u tey first approach..make  customer field as common to both tsble n rename state field.. How u expecting

The result..can u post a sample file n expecting result..by that can easy  to solve ur requirement..

Join , inner join, left join, concantenate concept also use to combine tables but without kowing the expected result its difficult to find

erich_shiino
Honored Contributor

Re: Dimension with no unique key

I might be missing something but given a sales order it's not possible to tell the right sales rep.

Using Mayil approach, you can create a more complex key, using Customer & '|' & State & '|' & Rep as Key, but there would be no link to the sales, right?

If you provide us some data samples, we can better understand the problem.

Regards,

Erich

Community Browser