Forum Discussion
First no blank with gorups()
Hi, I need to find last value (based on Date) for each group (Currency) and fill values if missing.
Table:
| Date | Currency | Exchange_rate |
| 01-07-2019 | EUR | 2.2 |
| 01-09-2019 | EUR | 2.1 |
| 01-01-2020 | EUR | |
| 03-02-2020 | EUR | 2 |
| 01-07-2019 | USD | 1.1 |
| 01-01-2020 | USD | |
| 01-01-2020 | USD |
The outcome should be (or it can be a new column with old and filled values):
| Date | Currency | Exchange_rate |
| 01-07-2019 | EUR | 2.2 |
| 01-09-2019 | EUR | 2.1 |
| 01-01-2020 | EUR | 2.1 |
| 03-02-2020 | EUR | 2 |
| 01-07-2019 | USD | 1.1 |
| 01-01-2020 | USD | 1.1 |
| 01-01-2020 | USD | 1.1 |
I believe it can be done easily in PowerBI, probably with firstnoblank(), but I wasn't albe to figure it out 😕 .
Can someone please help me to resolve this problem? Thank you!
Hi, Anonymous
Since your Table “Date” column has the same date, you also need to create an index column in ascending order of date in the advanced editor .
Then you can create a calculated column as below:
Column = VAR _index = IF ( 'Table'[Exchange_rate] <> BLANK (), 'Table'[Index], CALCULATE ( MAX ( 'Table'[Index] ), FILTER ( 'Table', 'Table'[Currency] = EARLIER ( 'Table'[Currency] ) && 'Table'[Index] < EARLIER ( 'Table'[Index] ) && 'Table'[Exchange_rate] <> BLANK () ) ) ) RETURN CALCULATE ( SUM ( 'Table'[Exchange_rate] ), FILTER ( 'Table', 'Table'[Index] = _index ) )Please check attached pbix file for more details.
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
Anonymous , Try fill down feature of power query if that suits
- AnonymousNot applicable
Hi amitchandak ,
thanks for your input. Unfortunatelly it does not suit to this scenario as Exchange_rate is a calculated column with lookupvalue() from another table. I forgot to mention that. This needs to be solved via calculated column also.- v-easonf-msftCommunity Support
Hi, Anonymous
Since your Table “Date” column has the same date, you also need to create an index column in ascending order of date in the advanced editor .
Then you can create a calculated column as below:
Column = VAR _index = IF ( 'Table'[Exchange_rate] <> BLANK (), 'Table'[Index], CALCULATE ( MAX ( 'Table'[Index] ), FILTER ( 'Table', 'Table'[Currency] = EARLIER ( 'Table'[Currency] ) && 'Table'[Index] < EARLIER ( 'Table'[Index] ) && 'Table'[Exchange_rate] <> BLANK () ) ) ) RETURN CALCULATE ( SUM ( 'Table'[Exchange_rate] ), FILTER ( 'Table', 'Table'[Index] = _index ) )Please check attached pbix file for more details.
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.