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
Prodosh
Frequent Visitor

Showing Previous Month /Current Month Values in Future Month values

Hi Team,

 

I have a requirement in which i need to update the Current Month value to Upcoming Month values that are showing null.For Example in the Below Scrrenshot the Sales value in Current month 2018/09 should get updated to 2018/10, 2018/11, 2018/12

Please find the Screenshot Below. Any Help would be appreciated. 🙂

 

 

 

monthsales.JPG

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @Prodosh,

 

We could use a measure like below. If you need the exact formula, please provide a dummy sample.

Measure 7 =
VAR lastDateHasSales =
    CALCULATE (
        LASTNONBLANK (
            'Calendar'[Date],
            CALCULATE ( SUM ( FactSales[SalesQuantity] ) )
        ),
        ALL ( 'Calendar' )
    )
RETURN
    IF (
        ISBLANK ( SUM ( FactSales[SalesQuantity] ) ),
        CALCULATE (
            SUM ( FactSales[SalesQuantity] ),
            FILTER (
                ALL ( 'Calendar' ),
                YEAR ( 'Calendar'[Date] ) = YEAR ( lastDateHasSales )
                    && MONTH ( 'Calendar'[Date] ) = MONTH ( lastDateHasSales )
            )
        ),
        SUM ( FactSales[SalesQuantity] )
    )

showing_previous_month

 

Best Regards,

Dale

Community Support Team _ Dale
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

11 REPLIES 11
Anonymous
Not applicable

I have created a new measure and break it down by months like shown below,

month 1=data in jan'2020
month 2=data in feb'2020
month 3=data in mar'2020
month 4=data in apr'2020
month 5=data in may'2020

Now, im having problem to display the previous months values in the current month row like the one shown below, im not sure how to get that results as expected.

month 1=data in dec'19
month 2=data in jan'2020
month3=data in feb'2020
month4=data in mar'2020
month 5=data in apr'2020
month 6=data in may'2020

Is there anyone having any idea about this?
My dashboard has only a year filter.

Hi @Anonymous  ,

 

Can you provide any sample data / screenshot regarding your requirement  . 

 

Thanks 

Prodosh 

Anonymous
Not applicable

sure here it is, i cannot use the previous month function because my values are in measures and it has filter in it and i have to use the Calculate function.

  Current data   Expected data
 monthmeasure  monthmeasure
       
20191-9712105329.827301 20201216477848.1
201928734366.182 20202'-15347451899.259367
2019379800885.36 20203'-24375508.06959456
20194'-6813238643.463575 2020423003857.52
20195'-199365784.79792812 20205'-79316170.69565716
20196'-1917799765.134318 2020626844790.12
2019760077560.55 202070
20198'-116559690.36106066 20208367394211.5
20199'-15173986.473717645 202090
201910'-6003066388.408958 2020100
20191149650715.74 2020110
201912216477848.1 2020120
20201'-15347451899.259367    
20202'-24375508.06959456    
2020323003857.52    
20204'-79316170.69565716    
2020526844790.12    
202060    
20207367394211.5    
202080    
202090    
2020100    
2020110    
2020120    

Hi @Anonymous  ,

 

Here is solution for your Sample Data for calculating previous month with screenshot Below 

 

Dax Query :  

Previous Month Sales = CALCULATE(SUM(Sheet1[Sales]),PREVIOUSMONTH('Dates'[Date]))
( For Calculating this you need to have the date dimension table in your pbix file .)

 

Hope this solution will work for you 🙂

 

Screenshot ,

 

community_pwerbi.PNG

Anonymous
Not applicable

Hi, 

Thanks for you reply but im afraid it did not work as the sales values are actually outcome of a measure, not a direct dataset. Im trying to get the previous measure values. Since, its a measure, i cant use the calculate function right. Let me know if you have any idea on it but thanks again!:) 

Hi @Anonymous ,

 

It doesn't matter for Sales value calculated which is outcome of  measures as you mentioned . As long as there is proper modelling and date dimension is working fine . the Previous month function will also work fine .

 

Usually calculate function always works for measures 🙂

 

By the way , which data source are you using for report .

Anonymous
Not applicable

Hi,

Thanks for the input. By measures i meant a newly created measure inside power bi.  This measure has a calculation and filtered with  few dimension. Hence, im not able to use the previousmonth function because it keeps giving me back the current month values.

v-jiascu-msft
Employee
Employee

Hi @Prodosh,

 

We could use a measure like below. If you need the exact formula, please provide a dummy sample.

Measure 7 =
VAR lastDateHasSales =
    CALCULATE (
        LASTNONBLANK (
            'Calendar'[Date],
            CALCULATE ( SUM ( FactSales[SalesQuantity] ) )
        ),
        ALL ( 'Calendar' )
    )
RETURN
    IF (
        ISBLANK ( SUM ( FactSales[SalesQuantity] ) ),
        CALCULATE (
            SUM ( FactSales[SalesQuantity] ),
            FILTER (
                ALL ( 'Calendar' ),
                YEAR ( 'Calendar'[Date] ) = YEAR ( lastDateHasSales )
                    && MONTH ( 'Calendar'[Date] ) = MONTH ( lastDateHasSales )
            )
        ),
        SUM ( FactSales[SalesQuantity] )
    )

showing_previous_month

 

Best Regards,

Dale

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

Hi @v-jiascu-msft

Thanks for your Reply. this logic is working fine.

Greg_Deckler
Super User
Super User

So, are you saying that those last 3 values should show the value for 2018/09 (441,600.11) instead of blank?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

yes

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.