Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Davideok
Contributor
Contributor

pick the value active in a certain period in time

Hi all,

I have a question on how to define the set analysis of a measure using data coming from multiple tables (to semplify let me use two tables) 

Attached the example

how can I create a measure "net Price" = "gross Price" * (1-"Discount") where the discount is the one active when the unit has been invoiced?

thank you for the help and the patience

Davide

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

you can try something like below. Make sue to replace field reference with your actual field names

// Your discount table
Discount_map:
mapping load Model& Floor((FromDate+IterNo()-1)) as Key,
Discount
FROM Table
While FromDate+IterNo()-1<=ToDate;

//main tale
Data:
load [Serial No],
[Invoice Date],
Model,
[Gross Price],
ApplyMap('Discount_map',Model&floor([Invoice Date]),1) as Discount
FROM Table;

View solution in original post

3 Replies
rubenmarin

Hi, I think it will be better if you assign the discount % to each row in script.

Using intervalmatch you can assign each % discount to the invoiceline.

https://help.qlik.com/es-ES/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

Check the example2 it uses ProductionLne as you should use Model to assign % by model and date range

Davideok
Contributor
Contributor
Author

Hi Ruben, thank you for the kind help.
I apologize for my bad understanding on how scripts work but I tried to replicate the example given in the link you sent and I don't get the result shown in the article (in the output table I don't see all the fileds).
Let me put it in a different way starting from the example in the link.
I run the intervalmatch but i need the field "Order" mapped into the table EventLog
How to do that?
thanks a lot
Davide

Kushal_Chawda

you can try something like below. Make sue to replace field reference with your actual field names

// Your discount table
Discount_map:
mapping load Model& Floor((FromDate+IterNo()-1)) as Key,
Discount
FROM Table
While FromDate+IterNo()-1<=ToDate;

//main tale
Data:
load [Serial No],
[Invoice Date],
Model,
[Gross Price],
ApplyMap('Discount_map',Model&floor([Invoice Date]),1) as Discount
FROM Table;