Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DAX How to express today "one month ago"

Tags:

powerbi

dax

I want to create a card with last month's sales using Power BI Desktop.

For that, I need a measure that is capable of expressing today "one month ago"

For example, this month's sales is:

This month sales =
VAR ThisMonth =
    MONTH ( TODAY () )
RETURN
    CALCULATE (
        'orders'[SalesAmount];
        'calendar'[month_number] = ThisMonth;
        'calendar'[year] = 2017
    )

All time intelligence functions seem to be good to handle columns of date but not scalar values like this case is.

Also, because I'm using a card, there's no "filter context", therefore, I need a volatile function like TODAY.

Thanks!


1 Answers

Can you just do

LastMonth = MONTH(EOMONTH(TODAY(),-1))

and use that instead of ThisMonth in your formula?

like image 184
Alexis Olson Avatar answered Sep 05 '25 15:09

Alexis Olson