Forum Discussion
mhsk
Helper II
7 years agoObtain single value from column with max values into a new column
Easy question: how to get just a single value from sumQty_by_item column? location part qty sum_qty_by_item date expected result 1 111 10 60 01.05.2019 60 2 111 20 60 0...
- 7 years ago
Hi mhsk
I would suggest you to add an index column in query editor.Then create the column as below:
Column = VAR pre_sum = CALCULATE ( MAX ( 'Table'[sum] ), FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 ) ) RETURN IF ( pre_sum <> 'Table'[sum], CALCULATE ( MAX ( 'Table'[sum] ), ALLEXCEPT ( 'Table', 'Table'[sum] ) ), 0 )Regards,
mhsk
Helper II
7 years agook this works while parts are always represented in multiple rows, but there are also cases where part can have just one row (no index-1 possible) - like part 555 below, could you have a look ?
| part | sum | expected result |
| 111 | 50 | 50 |
| 111 | 50 | 0 |
| 111 | 50 | 0 |
| 222 | 60 | 60 |
| 222 | 60 | 0 |
| 222 | 60 | 0 |
| 333 | 1 | 1 |
| 333 | 1 | 0 |
| 333 | 1 | 0 |
| 444 | 10 | 10 |
| 444 | 10 | 0 |
| 444 | 10 | 0 |
| 555 | 15 | 15 |
v-cherch-msft
Microsoft Employee
7 years ago