Forum Discussion
Previous Month value
- Anonymous3 years ago
Hi Anonymous ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
1. Create a date dimension table
Date = CALENDAR(date(2022,1,1),TODAY())2. Create a measure as below
Measure = VAR _selmonth = SELECTEDVALUE ( 'Date'[Date].[MonthNo] ) VAR _maxdate = CALCULATE ( MAX ( 'Table'[Data] ), ALLSELECTED ( 'Table' ) ) VAR _month = MONTH ( _maxdate ) VAR _lastvalue = CALCULATE ( SUM ( 'Table'[value] ), FILTER ( ALLSELECTED ( 'Table' ), YEAR ( 'Table'[Data] ) = YEAR ( _maxdate ) && MONTH ( 'Table'[Data] ) = _month ) ) RETURN IF ( _selmonth <= _month, SUM ( 'Table'[value] ), _lastvalue )If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi Anonymous
You can write a DAX and calculate a calculated column that says if the value is blank then take previous month value.
= IF(ISBLANK(value), CALCULATE(SUM(value), PREVIOUSMONTH(Date)), SUM(value))
For this please refer the document for PREVIOUSMONTH DAX formula.
Hope this helps!
Thank you
- Anonymous3 years agoNot applicable
Thank you for your reply. Sadly that did not work: