Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

How to Calculate MTD Change using two different date values?

Hi, 

I am working on a sales forecasting report and I am struggling on how to create a measure that would calculate the sum of 'Sales Data' [sales_price] but only for sales that had an order date and invoice date in the current month (MTD). 

My table 'Sales Data' has the following fields I need to use:

[sales_price]

[order_date]

[invoice_date]

*also i need this to update with my date slicer that is using another measure 'FullDateKey'. There is a relationship for this measure between the date and the 'sales data'[invoice_date], not the order date.*


Thanks!

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous 

     

    First of all, measure can't be put into the slicer.You can create a date table using the following formula, and then create a relationship between the date table and the invoice_date column.

    FullDateKey = CALENDAR(DATE(2024,1,1),DATE(2024,12,31))

     

    Based on your needs, I have created the following table.

     

    You can calculate total sales using the following Dax:

    Measure = SUMX(FILTER('Table','Table'[invoice_date]<>BLANK()&&'Table'[order_date]<>BLANK()),'Table'[sales_price])

     

    Result:

     

     

    Best Regards,

    Jayleny

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

     

    First of all, measure can't be put into the slicer.You can create a date table using the following formula, and then create a relationship between the date table and the invoice_date column.

    FullDateKey = CALENDAR(DATE(2024,1,1),DATE(2024,12,31))

     

    Based on your needs, I have created the following table.

     

    You can calculate total sales using the following Dax:

    Measure = SUMX(FILTER('Table','Table'[invoice_date]<>BLANK()&&'Table'[order_date]<>BLANK()),'Table'[sales_price])

     

    Result:

     

     

    Best Regards,

    Jayleny

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.