Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I'm trying to over write a value coming from DB table with some calculations. Tried if condition on expression but not working. Please can someone let me know how to solve ?
A result should be 350/200 = 1.75
DB values:
| Dimension | value |
| A | 100 |
| B | 200 |
| C | 350 |
I have used total in set analysis and it worked.
If(dim = ‘A’, sum(total {<dim = {‘B’}>} value)/sum(total {<dim = {‘C’}>} value))
trying to picture what you want to happen, can you pls create a table:
| Dimension | expression result |
| A | 100/200 = .5 is this expected for A? |
| B | 200/200 = 1 ? is this expected for B? |
| C | 350/200=1.75 |
Hi Edwin,
Thanks for your reply. I'm getting monthly data from DB for each value in dimension where i created yearly data in qlik script as the user wants to see yearly data also. For some of the dimensions i need to apply calculations on top of what am getting from DB. In the above example i have a value for A , B, C from DB where am showing both monthly and yearly data. For monthly data i should not apply any calculation for A but coming to yearly data i need to apply calculation for A value to be calculated by A= C/B.
Expected output:
| ion | value |
| A | 1.75 |
| B | 200 |
| C | 350 |
I have used total in set analysis and it worked.
If(dim = ‘A’, sum(total {<dim = {‘B’}>} value)/sum(total {<dim = {‘C’}>} value))
if your table is strictly what youve pasted, you wouldnt need to add "TOTAL"
or at least SHOULDNT need to add TOTAL