Forum Discussion

datamortar's avatar
datamortar
Frequent Visitor
3 years ago

Measure with filtering from two date fields

I have a data model with a measure for order amount. For simplicity:
-Fact table has four columns: order number, order amount, delivery_date, order_date.
-The fact table is connected with a dim table (Calendar) to the order_date column.

 

I need to calculate orders for the current order_date period (filtered with a slicer) BUT
it should exclude orders with delivery_dates that are outside the region.


I have tried to explicitly define the filter in the calculate but it seems to always also
include the implicit filters and/or include too much of the dim. I would like to have the result on the same granularity as the fact. Any suggestions?

 

I have tried (to no avail) : 

order amount = CALCULATE(
SUM (Sales[orders]),

FILTER('Sales',
Sales[delivery_date] <= CALCULATE(
MAX('Calendar'[Date]),KEEPFILTERS('Calendar'[Date]))))

2 Replies

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi, datamortar 

     

    Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures. I look forward to your response.

    Best Regards,

    Community Support Team _Charlotte

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