Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all!!
I have this data table:
datekey_ym | id | id_ant | centro_costos | cve_sku | Inicial | Final |
202009 | 202009|4101|0000000185 | 202010|4101|0000000185 | 4101 | 0000000185 | 10 | 0 |
202010 | 202010|4101|0000000185 | 202011|4101|0000000185 | 4101 | 0000000185 | 6 | 0 |
202011 | 202011|4101|0000000185 | 202012|4101|0000000185 | 4101 | 0000000185 | 6 | 0 |
and I need that the expression 'final' shows the sum of expresion Inicial where id = id_ant, something like this:
datekey_ym | id | id_ant | centro_costos | cve_sku | Inicial | Final |
202009 | 202009|4101|0000000185 | 202010|4101|0000000185 | 4101 | 0000000185 | 10 | 6 |
202010 | 202010|4101|0000000185 | 202011|4101|0000000185 | 4101 | 0000000185 | 6 | 6 |
202011 | 202011|4101|0000000185 | 202012|4101|0000000185 | 4101 | 0000000185 | 6 | 0 |
I try with this expression: sum({<id={"=id_ant"}>} Inicial) but it doesn't work.
could anyone help me please?
Thanks a lot!!
Both id and id_ant values are not equal in the same row. so that, its gives zero value.
Based on ur sample, its looks like , Id_ant value is next line Id values? if so, you can try like below
LOAD *, Peek(id_ant) as id_Ant1 INLINE [
datekey_ym, id, id_ant, centro_costos, cve_sku, Inicial, Final
202009, 202009|4101|0000000185, 202010|4101|0000000185, 4101, 0000000185, 10, 0
202010, 202010|4101|0000000185, 202011|4101|0000000185, 4101, 0000000185, 6, 0
202011, 202011|4101|0000000185, 202012|4101|0000000185, 4101, 0000000185, 6, 0
];
Exp: sum({<id={"=id=id_Ant1"}>} Inicial)