Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
anoonymous
Helper I
Helper I

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.

Same thing should also happen to october. So baisically both  should be 600.

If there is any data coming in for september, 600 should be relplaced by the actual value.

 

EDIT

Informations you might need: 

Since I can't show you the actual data I created random tables to give you guys more detail:

 

This is what my issue looks like:

anoonymous_0-1665751411910.png

September and october are both empty since there is no data: 

 

anoonymous_1-1665751563264.png

 

 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @anoonymous ,

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 )

yingyinr_2-1665998927292.png

 

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
v-yiruan-msft
Community Support
Community Support

Hi @anoonymous ,

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 )

yingyinr_2-1665998927292.png

 

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Maybe there is a chance you can tell me how I can use the value for a running total..

Thank you 🙂 It worked perfectly 🙂 

singhsudha1301
Frequent Visitor

Hi @anoonymous 

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

Thank you for your reply. Sadly that did not work:

anoonymous_0-1665751135808.png

 

AbbasG
Memorable Member
Memorable Member

@anoonymous Hi this can be done in power query through the fill option.

Go to power query==>right-click the value column==>Click on Fill ==> Down.

 

AbbasG_0-1665747682906.png

Below is the output. Hope this helps.

AbbasG_1-1665747717292.png

 

Thank you for your quick answer. But that did not work. I added some further information maybe you can take a look? 

@anoonymous fill option did not work? or did you get any errors? Please share some more information it will help me better

AbbasG
Memorable Member
Memorable Member

@anoonymous Also when I replace the data in the source file, it also updates the corresponding month with its actual value.

Hello 🙂 It's not working because the data you are using is not the the actual data. I edited my post. March -> September is the visual table. I added an datatable to show you what my actual data looks like. By following your steps nothing happend at all. The visual is still empty 😞 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.