Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Previous Month value

Hello guys,   I really hope someone can help me figuring this out.   My Question:  Since I have no data for september yet I am trying to fill it with the value before, but I can't figure out how...
  • Anonymous's avatar
    Anonymous
    3 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