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: 
Not applicable

Sql data load issue - pivoting

Hi,

I have connected Qlik sense with a database and want to load the following data. The Sql query is below. However I am having trouble loading the data due to error in the following codes. Can someone suggest why this doesn't work?

Thanks.

    LOAD ID,

        ComponentSales,

        Sales,

        Territory,

        Volume,

        ComponentName,

        "Type"

    SQL with relevantComponents as

    (

                select [ComponentName], [Value], [Type] from SALESREPORTING.dbo.Components

                where ([ReportRunId] = 901) AND ([AggregationId] = 'MainOneMonth')

    )

    SELECT *

    FROM relevantComponents

    pivot (

                max([Value])

                for [Type] in ([ComponentSales], [Sales], [Territory], [Volume])

    )

                as datapivot;

5 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try adding a semicolon after "Type". A preceding load needs to be terminated with a ; character.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert, thank you for the suggestion. I've added a semicolon after type but it still does not load... Can you see anything else wrong with it?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

I don't see a field ID anywhere in the sql statement.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert, sorry I don't understand... aren't ID, ComponentSales, etc field IDs?

Thanks.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

   LOAD ID,

        ComponentSales,

        Sales,

        Territory,

        Volume,

        ComponentName,

        "Type"

You tell Qlikview to load a field called ID. Where does that field come from? I don't see it in the sql statement.


talk is cheap, supply exceeds demand