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: 
helena11
Contributor II
Contributor II

Revenue for different date ranges by country in one table

Dear community,

I am struggling with a set expression to display the Sum(Revenue) achieved by each country within a promotion time frame. The problem is, that the products included in the promotion and the time frame for the promotion differ across countries although its the same promotion.

This is a simplified version of my data model:

helena11_2-1634548806447.png

 

And this is what the final table should contain:

helena11_1-1634548084206.png

Now I do get this to work if the user selects only one country from the filter pane and in consequence only one country is displayed in the table. The formula for that looks like this:

Sum({<[Order Date]={">=$(=Only([Promotion Start]))<=$(=Only([Promotion End]))"}>} If(Wildmatch([Country Name],GetFieldSelections([Country]),[Revenue]))

But as soon as I want to have one table that contains all countries I run into problems as how to account for the different date ranges and product ranges for each country. Does anyone have a suggestion how I could solve this? 

 

Thanks in advance

1 Solution

Accepted Solutions
abhijitnalekar
Specialist II
Specialist II

Hi @helena11 ,

Please check the below script.

 

Mcountry:
mapping
LOAD
OrderCountryID,
CountryName
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is [Country Detail]);

Moroder:
Mapping
LOAD
OrderID,
ProductID
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is [Order Detail]);

 

Tab1:

LOAD
"Order ID" as OrderID,
OrderCountryID,
ApplyMap('Mcountry',OrderCountryID) as CName,
Applymap('Moroder',"Order ID") as ProductID,
"Order Date",
Revenue
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is [Order Review]);


LOAD

Country as CName,
"Promotion Start",
"Promotion End"
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is PramotionDetail);

 

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!

View solution in original post

6 Replies
abhijitnalekar
Specialist II
Specialist II

Hi @helena11 ,

 

Are you looking for the same result for revenue?

 

abhijitnalekar_0-1634569575464.png

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
helena11
Contributor II
Contributor II
Author

Hi @abhijitnalekar 

no, actually I am looking for a different revenue per country.

abhijitnalekar
Specialist II
Specialist II

Hi @helena11 

Please check the below output. hope you are looking the same.

abhijitnalekar_0-1634625700674.png

Please check the attached QVF for reference. 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
helena11
Contributor II
Contributor II
Author

Hi @abhijitnalekar 

if you solved it with a set expression can you maybe post it here? My company does not allow the import of external QVF files.

Thanks

abhijitnalekar
Specialist II
Specialist II

Hi @helena11 ,

Please check the below script.

 

Mcountry:
mapping
LOAD
OrderCountryID,
CountryName
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is [Country Detail]);

Moroder:
Mapping
LOAD
OrderID,
ProductID
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is [Order Detail]);

 

Tab1:

LOAD
"Order ID" as OrderID,
OrderCountryID,
ApplyMap('Mcountry',OrderCountryID) as CName,
Applymap('Moroder',"Order ID") as ProductID,
"Order Date",
Revenue
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is [Order Review]);


LOAD

Country as CName,
"Promotion Start",
"Promotion End"
FROM [lib://test/Dump.xlsx]
(ooxml, embedded labels, table is PramotionDetail);

 

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
helena11
Contributor II
Contributor II
Author

Hi again @abhijitnalekar ,

thanks for your help. I tried your solution with the mapping tables and it worked.