Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
I face a difficulty with how to bring calculation into inline table and then how to use it as measure within table object. The idea is to take fields from DB table (in example below it is a "Numbers" table). And then in inline table "Test" create several dimetions and associate them with particular calculations. I need to do this to have possibility sow in pivot table different calculations aggregated by created dims.
But as long as I tried I have no luck with how to specify calculation correctly within "Test" table and then use them ad measure within pivot to achieve calculation results. I will appreciate any hint regarding this.
Numbers:
Load* Inline [
F1, F2
1, 4
2, 5
3, 6
];
test:
LOAD * INLINE [
ParentLevel, ChildLevel, Calculation
'Total', 'First', 'Sum(F1)'
'Total', 'Second', 'Sum(F2)'
'Total', 'Third', 'Sum(F1-F2)'
'Row', 'Row High', 'Sum(F1)-20'
'Row', 'Row Low', 'Avg(F2)'
];
I think this code snippet does what you've indicated.
Numbers:
Load
Sum(F1) as Sum_F1,
Sum(F2) as Sum_F2,
Avg(F2) as Avg_F2
Inline [
F1, F2
1, 4
2, 5
3, 6
];
test:
Load
ParentLevel,
ChildLevel,
Evaluate(Calculation)
Inline
[
ParentLevel, ChildLevel, Calculation
Total, First, "Peek('Sum_F1',0,'Numbers')"
Total, Second, "Peek('Sum_F2',0,'Numbers')"
Total, Third, "Peek('Sum_F1',0,'Numbers')-Peek('Sum_F2',0,'Numbers')"
Row, Row High, "Peek('Sum_F1',0,'Numbers')-20"
Row, Row Low, "Peek('Avg_F2',0,'Numbers')"
];
@Peony I am not sure I understand fully, but can't you just define variables for the calculations?
You can then use the variables in the UI as needed.
@pravinboniface I'm afraid onse I will associate particular dimension with particular variable inside table object using 'IF' condition this will overload UI with calculation. So I hope to find a way to associate dims and calculation within load script
I think this code snippet does what you've indicated.
Numbers:
Load
Sum(F1) as Sum_F1,
Sum(F2) as Sum_F2,
Avg(F2) as Avg_F2
Inline [
F1, F2
1, 4
2, 5
3, 6
];
test:
Load
ParentLevel,
ChildLevel,
Evaluate(Calculation)
Inline
[
ParentLevel, ChildLevel, Calculation
Total, First, "Peek('Sum_F1',0,'Numbers')"
Total, Second, "Peek('Sum_F2',0,'Numbers')"
Total, Third, "Peek('Sum_F1',0,'Numbers')-Peek('Sum_F2',0,'Numbers')"
Row, Row High, "Peek('Sum_F1',0,'Numbers')-20"
Row, Row Low, "Peek('Avg_F2',0,'Numbers')"
];
Try something like this,
https://community.qlik.com/t5/QlikView-App-Dev/Date-selections-on-Multiple-Date-fields/td-p/1700299
I dont know if is the best solution but works the expression:
$(=Concat('If(Calculation='''&Calculation&''','&Calculation,',')&Repeat(')',Count(Calculation)))
If your expressions have dollar function you need to create variables in script replacing with other characters like:
Replace('$(_vExp)','!@#%',Chr(36))
@lblumenfeld Thank you for help. Your idea works perfectly well!