Forum Discussion

Mahfuz's avatar
Mahfuz
Frequent Visitor
3 years ago
Solved

SPLM data without consider date filter

i have calculate same period last month using the below dax

SPL_Month_KG_Card =

CALCULATE (
    [sales in kg], -- Replace [sales in kg] with the actual measure for sales in kg.
    DATEADD('Global Date'[Date],-1,MONTH) -- Calculate the same period last month until today.
)
but the problem is to get the correct answer, I need to select the date filter. How can I get the fixed output for last month's value without any date filter selection or if I select any date, it will give me the last month's data based on the system's current month and date. Thanks in advance


  • Try

    Same period last month =
    VAR ThisMonth =
        CALCULATETABLE (
            DATESMTD ( 'Global Date'[Date] ),
            TREATAS ( { TODAY () }, 'Global Date'[Date] )
        )
    VAR Result =
        CALCULATE ( [sales in kg], DATEADD ( ThisMonth, -1, MONTH ) )
    RETURN
        Result
    

2 Replies

  • Try

    Same period last month =
    VAR ThisMonth =
        CALCULATETABLE (
            DATESMTD ( 'Global Date'[Date] ),
            TREATAS ( { TODAY () }, 'Global Date'[Date] )
        )
    VAR Result =
        CALCULATE ( [sales in kg], DATEADD ( ThisMonth, -1, MONTH ) )
    RETURN
        Result