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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX help with Dateadd and TODAY()-1 for MoM calculation

Hello,

 

I'm trying to create a calculation that finds Month over Month % as:  (Current MoM - Prior MoM) / Prior MoM

 

Current MoM calculation is: CALCULATE(SUM(factSales[QuantityShipped]),filter('Date','Date'[Date]=today()-1 )) which gives me the Quantity Shipped amount for Nov 19.

 

I need Prior MoM to be the Quantity Shipped amount for Oct 19, so I was wanting the filter to be something like filter('Date','Date'[Date]=dateadd(today()-1,-1,MONTH ))  but that has an issue with today()

 

I also need to account for end of month dates not matching up, but that can be step 2.

 

 

How can I fix the Prior MoM calculation?

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous,

 

The DATEADD function only accepts one column as parameter try the following measure I have already made it to work with change of year.

 

PMOM =
VAR Date_select =
    IF (
        MONTH ( TODAY () ) = 1;
        DATE ( YEAR ( TODAY () ) - 1; 12; DAY ( TODAY () - 1 ) );
        DATE ( YEAR ( TODAY () ); MONTH ( TODAY () ) - 1; DAY ( TODAY () - 1 ) )
    )
RETURN
    CALCULATE (
        SUM ( Table1[sales] );
        FILTER (
            'Date';
            'Date'[Date]
                = DATE ( YEAR ( TODAY () ); MONTH ( TODAY () ) - 1; DAY ( TODAY () - 1 ) )
        )
    )

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous,

 

The DATEADD function only accepts one column as parameter try the following measure I have already made it to work with change of year.

 

PMOM =
VAR Date_select =
    IF (
        MONTH ( TODAY () ) = 1;
        DATE ( YEAR ( TODAY () ) - 1; 12; DAY ( TODAY () - 1 ) );
        DATE ( YEAR ( TODAY () ); MONTH ( TODAY () ) - 1; DAY ( TODAY () - 1 ) )
    )
RETURN
    CALCULATE (
        SUM ( Table1[sales] );
        FILTER (
            'Date';
            'Date'[Date]
                = DATE ( YEAR ( TODAY () ); MONTH ( TODAY () ) - 1; DAY ( TODAY () - 1 ) )
        )
    )

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



tjlee
Frequent Visitor

Try this formula

EOMONTH(TODAY(),-1)

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.