Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dataguy46
Contributor III
Contributor III

Delimited seperated values as column header

Hello All,

 I have a delimiter seperated value in one column called `Tags`,

I have used Subfield function to seperate each values , but i am not able to get the value before the delimiter to fix it as column header,

example value of tag field:

{"application":"Domain Controllers","Environment":"Production","Owner":"Systems","CostCenter":"Infra","ApplicationService":"Active Directory","tagVM":"vmwcushnetdc02","tagOrigin":"Migrated"}

Expected output in image:

Dataguy46_0-1722947410785.png

thanks in advance,

Regards,

Adithya

 

Labels (1)
16 Replies
Or
MVP
MVP

Looks like you're basically reading .json? Even if it's not a .json file, you should be able to adapt the same solution, I think.

https://community.qlik.com/t5/Member-Articles/How-to-read-json-files-with-Qlik-Sense/ta-p/2120598

 

Dataguy46
Contributor III
Contributor III
Author

Hi Or,

I am loading this from a database, hence i think we cant solve this using the method you have suggested.

Or
MVP
MVP

I don't see why not, but perhaps I'm missing something?

Or_0-1722950738276.png

 

Dataguy46
Contributor III
Contributor III
Author

This is the script, 

test:

LOAD
Tags,
SubField(Tags,',',1) as A,
SubField(Tags,',',2) as B,
SubField(Tags,',',3) as C,
SubField(Tags,',',4) as D,
SubField(Tags,',',5) as E,
SubField(Tags,',',6) as F,
SubField(Tags,',',7) as G,
SubField(Tags,',',8) as H

FROM [lib://SharedDataSources:DataFiles/test.qvd] (qvd);

and the output i got is 

Dataguy46_0-1722951098533.png

but the expected output is attached in the question,

i am not able to use your method since its not a .json file

 

Or
MVP
MVP

It doesn't need to be a file. You just need to use (json) to treat it as a Jason file. I used an inline load for mine, though it doesn't seem to be a documented option, with no issues:

Load * INLINE [
{"application":"Domain Controllers","Environment":"Production","Owner":"Systems","CostCenter":"Infra","ApplicationService":"Active Directory","tagVM":"vmwcushnetdc02","tagOrigin":"Migrated"}] (json);

I imagine if you read your original and then stored it into a text file or whatnot, you could read that file as json.

If that doesn't work for you, another approach you could use is:

https://community.qlik.com/t5/New-to-Qlik-Analytics/Qlik-Sense-parsing-of-a-json-field/td-p/1795740

 

Dataguy46
Contributor III
Contributor III
Author

I saved my table in Txt format and tried to read it as .json, but i am getting error.

Dataguy46_0-1723119418560.png

 

Venkat7
Contributor II
Contributor II

write like this 

 

subfield(tagfield,':',-1)  as your_required

 

 

you will get a answer 

Kushal_Chawda

@Dataguy46  Try below

Generic
Load Tag,
         SubField(Values,':',1) as Field_Name,
         SubField(Values,':',2) as Field_Values;
Load Tag,
         SubField(PurgeChar(Tag,'"{}'),',') as Values
FROM [lib://SharedDataSources:DataFiles/test.qvd] (qvd);

Dataguy46
Contributor III
Contributor III
Author

Hello Venkat, tried that, but i need both attribute and values, like the screenshot below

Dataguy46_0-1723122458182.png

and this my input example:

{"application":"Domain Controllers","Environment":"Production","Owner":"Systems","CostCenter":"Infra","ApplicationService":"Active Directory","tagVM":"vmwcushnetdc02","tagOrigin":"Migrated"}

and this is how the field tags looks like,

Dataguy46_1-1723122540793.png