Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I have a dataset like the one below.
Month | id | Value |
Jan | 1 | 15 |
Jan | 2 | 25 |
Feb | 2 | 25 |
Feb | 3 | 5 |
Feb | 4 | 10 |
I want to sum the "Value " according to the distinct id field. First I want to find the total values by months, but then compare the total value over all months. And I want the result as follows. How can I do it, can you help?
month | sum(value) |
total | 55 |
jan | 40 |
feb | 40 |
Hope you can help me
Hi @esraltnl
For Total alone, you want to change the value, in that case, try like below
If(RowNo() =0 or IsNull(RowNo()), sum(aggr(sum(distinct Value),id)), Sum(Value))
in script ?
script
data:
LOAD * Inline [
Month,id,Value
Jan,1,15
Jan,2,25
Feb,2,25
Feb,3,5
Feb,4,10
];
set analysis
sum(aggr(sum(Value),id,Month))
Hi @esraltnl
For Total alone, you want to change the value, in that case, try like below
If(RowNo() =0 or IsNull(RowNo()), sum(aggr(sum(distinct Value),id)), Sum(Value))
thank you for answering