Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
DyadyaFedor
Contributor III
Contributor III

measure to dimension in load script?

My DB contains fields item, revenue and quantity. Inside the app, it's no problem to calculate price of every item by simply dividing sum(revenue)/sum(quantity), but it will be a measure.

What if I need price as a dimension? can I write same expression in my load script? How do I specify aggregation level? Let's say I have one more field, i.e. Country. and I have country 1, country 2. then, I would need price 1 for country 1-item1 and price 2 for country2 - item 1 

2 Replies
Lauri
Specialist
Specialist

To aggregate, you use 'group by' on the fields:

PriceData:
Load
Country,
item,
Sum(revenue)/Sum(quantity) as Price
From SourceData
Group By Country, item;

DyadyaFedor
Contributor III
Contributor III
Author

Thank you Lauri. Your solution works.

I've just realized that in my case simply writing "revenue/quantity as price" without any grouping serves my purpose better.

But thank you very much anyway!