Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
apichana
Contributor III
Contributor III

How to use new filed and how to solve synthetic key

Hi, 

 I have below coding and I would like to create the new field ' PLATE_Month' like this 

-- > PLATE_NO&'_'& PostDate_MonthNew as [PLATE_Month], and then I would like to group by PLATE_Month in another Table (Table2).  But I got 1 synthetic key how to solve that? Please advise. 

Table1: 

Load *,
PLATE_NO&'_'&PostDate_MonthNew as PLATE_Month;

LOAD
Date([POST_DATE]) AS [POST_DATE-PostDate],
Month([POST_DATE]) AS [POST_MONTH-PostDate],
[POST_DATE],

Plate_NO, 

if(day([POST_DATE])<=25,month([POST_DATE]),month(AddMonths([POST_DATE],1))) AS [PostDate_MonthNew],

RowNo() as RowCount,

FROM [lib://FM/Fleet_Card_*.qvd]
(qvd)

Table2: 
Load
 PLATE_NO as PLATE_NO_NEW,
PLATE_Month,
Count (RowCount) as PlateRowCount,

If(Sum(E20E85Consumption)/Count(RowCount) = '0','Action Need','Ok') as Action_Need
Resident Table1
Group by PLATE_NO,PLATE_Month;

 

1 Solution

Accepted Solutions
Rodj
Luminary Alumni
Luminary Alumni

The synthetic key is occurring because you have two or more columns with the same name in different tables. This will be very obvious when you look at the "data model viewer" as it creates a separate little table with the synthetic key columns in it, so you'll be able to tell from there. In this case I can't see an obvious candidate so I think there may be another issue with your script so that it isn't doing what you want it to. Is this the whole script or have you cut bits out? In any case, take a look at the model viewer and work from there.

View solution in original post

5 Replies
RayArina
Contributor III
Contributor III

Hi!

Can you share with us your table`s examples?

RayArina
Contributor III
Contributor III

a few rows are enough

apichana
Contributor III
Contributor III
Author

Hi, 

I have tried sending the sample table but always get this error message. I don't know why?

our post has been changed because invalid HTML was found in the message body. The invalid HTML has been removed. Please review the message and submit the message when you are satisfied.

Rodj
Luminary Alumni
Luminary Alumni

The synthetic key is occurring because you have two or more columns with the same name in different tables. This will be very obvious when you look at the "data model viewer" as it creates a separate little table with the synthetic key columns in it, so you'll be able to tell from there. In this case I can't see an obvious candidate so I think there may be another issue with your script so that it isn't doing what you want it to. Is this the whole script or have you cut bits out? In any case, take a look at the model viewer and work from there.

apichana
Contributor III
Contributor III
Author

Hi, 

Thanks a lot for your advice. It doesn't the whole script that I sent. So I'll take a look as advice.