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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
AntonioFreitasW
New Member

Dateadd not working with calculatetable

 Hi folks!

I need to find payments that exist in a specific month, but don´t appear in the following month.

I´m trying to create 2 dynamic tables with payments with due date on the context month and previous month, so I can use EXCEPT to find them. 
But when I try to create the table with payments due on the previous month, I still get only payments due on the context month...
Any idea what I´m doing wrong ? Here´s the DAX code:
    OnlyPrev =
       VAR CurrentMonth = MONTH(MAX(Calendar[Data]))
       VAR PrevMonth = MONTH(DATEADD(MAX(Calendar[Data]), -1, MONTH))
       RETURN
            CALCULATETABLE(
            PaymentTable,
            FILTER(
                  PaymentTable,
                  MONTH(PaymentTable[DueDate]) <> CurrentMonth &&
                  MONTH(DATEADD(PaymentTable[DueDate], -1, MONTH)) = PrevMonth
            )
        )

Thanks a lot for your help!

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Not sure how to paste excel here. I tried with copy and paste, but got an HTML error message...

amitchandak
Super User
Super User

@AntonioFreitasW , If dynamic means if should consider a filter or slicer, it will not. Tables are static 

 

You can try like

 

CALCULATETABLE(
PaymentTable,
FILTER(
PaymentTable,
EOMONTH(PaymentTable[DueDate],0) <> eomonth(today(),0) &&
EOMONTH(PaymentTable[DueDate],0) = eomonth(today(),-1)
)

 

 

The measure can be dynamic and you can use time intelligence for that

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks a lot for the answer!
I tried your suggestion, but replacing TODAY() for the SELECTED Date, and it gave me a "Circular error" message...

 SoTemAntes =
      CALCULATETABLE(
      ContasaReceber,
      ALL(ContasaReceber),
      FILTER(ContasaReceber,
            EOMONTH(ContasaReceber[Data Vencimento],0) <> eomonth(SELECTEDVALUE(Datas[Datas]),0) &&
            EOMONTH(ContasaReceber[Data Vencimento],0) = eomonth(SELECTEDVALUE(Datas[Datas]),-1)
))
any idea what can be wrong ? 
thanks a lot for your help!

@AntonioFreitasW , Table are static, using selectedvalue will not result dynamic values

 

Use measures with help from Time intelligence

 

 

example

 


MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Measures will give me single values right ?
That´s not what I´m looking for...
I need to generate a table with the customers´ payments that appear on one month and doesn´t appear on the next (selected). That´s why I need to generate a table.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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