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
prabhuss
Helper I
Helper I

PREVIOUSMONTH in not working if Time select is Jan 2018

Hi All,

Wishing you happy new year. Starting this new year, we observed one of our 

dashboard is not working. This dashboard is suppored to compare between Current month Sales vs Previous Months Sales. As of Jan 2018, Current month is going to be Jan 2018 and Previous month is going to be Dec 2017.

 

we are using following formula to calculate previous month sales

PrevMonthSale = CALCULATE(SUM(CustomerInvoice[PayableAmount]),  PREVIOUSMONTH(CustomerInvoice[InvoiceDate])).

 

Any help to resolve this is very well appriciated as we are using this dashboard activily 

 

Regards,

Prabhu Srivastava

 

 

1 ACCEPTED SOLUTION

@prabhuss,

Create the measure using one of the DAX below,  then use Year field and Month field of Datetable to create slicers.

PrevMonthSale = CALCULATE(SUM(CutsomerInvoice[PayableAmount]),  PREVIOUSMONTH(DateTable[Date]))
PrevMonthSale1 = 
CALCULATE (
    SUM ( CutsomerInvoice[PayableAmount] ),
    DATEADD ( DateTable[Date], -1, MONTH )
)

1.JPG

2.JPG

Regards,
Lydia

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

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

@prabhuss

 

Try this one

 

PrevMonthSale =
CALCULATE (
    SUM ( CustomerInvoice[PayableAmount] ),
    DATEADD ( CustomerInvoice[InvoiceDate], -1, MONTH )
)

Regards
Zubair

Please try my custom visuals

I had tried earlier, and did not work for me. Even , PrevMonth = CALCULATE(SUM(CustomerInvoice[PayableAmount]),  PARALLELPERIOD(CustomerInvoice[InvoiceDate],-1,MONTH)) did not work.

 

 

@prabhuss

 

Your formula will also work fine. Just add a Calendar Table using CalendarAuto() function. Then create a relationship between CalendarTable and Invoice Date.

 

PrevMonthSale = CALCULATE(SUM(CustomerInvoice[PayableAmount]),  PREVIOUSMONTH(CustomerInvoice[InvoiceDate]))


Regards
Zubair

Please try my custom visuals

CalendarAuto()  does not work for directquery. The trick i played that I  created SQL Table  called DateTable and

Then created a relationship between DateTable and Invoice Date.

 

@prabhuss,

Create the measure using one of the DAX below,  then use Year field and Month field of Datetable to create slicers.

PrevMonthSale = CALCULATE(SUM(CutsomerInvoice[PayableAmount]),  PREVIOUSMONTH(DateTable[Date]))
PrevMonthSale1 = 
CALCULATE (
    SUM ( CutsomerInvoice[PayableAmount] ),
    DATEADD ( DateTable[Date], -1, MONTH )
)

1.JPG

2.JPG

Regards,
Lydia

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

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.