Forum Discussion
PBInewbee123
3 years agoFrequent Visitor
Show last data from month
Hi,
I need some help 🙂
I have a dataset which shows me the stock value per week (situation picture we take every Sunday). With this an evolution chart is created. However, now we also want to see the evolution per month. For this, I want to use the last value of the month (iso average or sum)
Here below an example of the data that I have
| Date | Value |
2022-09-04 | 1000 |
| 2022-09-11 | 1200 |
| 2022-09-18 | 1100 |
| 2022-09-25 | 900 |
| 2022-10-02 | 950 |
| 2022-10-09 | 1100 |
| 2022-10-23 | 1100 |
| 2022-10-30 | 1000 |
Result that I want to end up wihth:
| Month | Value |
| 2022-09 | 900 |
| 2022-10 | 1000 |
Thank you!
Hi, PBInewbee123
You can add a calendar table with a column 'YearMonth'.
Then try measure like:
M_VALUE = VAR _lastdate = CALCULATE ( LASTDATE ( 'Table'[Date] ), ALLEXCEPT ( 'Calendar', 'Calendar'[YearMonth] ) ) RETURN CALCULATE ( MAX ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[Date] = _lastdate ) )Best Regards,
Community Support Team _ Eason
2 Replies
- MFelix
Super User
Hello,
Try the following code:
Last Value = MAXX(TOPN(1, 'Table', 'Table'[Date],DESC), 'Table'[Value]) - v-easonf-msft
Community Support
Hi, PBInewbee123
You can add a calendar table with a column 'YearMonth'.
Then try measure like:
M_VALUE = VAR _lastdate = CALCULATE ( LASTDATE ( 'Table'[Date] ), ALLEXCEPT ( 'Calendar', 'Calendar'[YearMonth] ) ) RETURN CALCULATE ( MAX ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[Date] = _lastdate ) )Best Regards,
Community Support Team _ Eason