Forum Discussion

PKPK90's avatar
PKPK90
Icon for Helper I rankHelper I
1 year ago
Solved

Measure Date range

The issue is that despite applying the same date filter, two measures—SumQuantityADJ and SumQuantity6Weeks—are returning different results. Both measures are intended to sum values from the 'Material...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi PKPK90 ,

    To your question below are some of my thoughts:

     

    1. Date Filter Application: Ensure that the NewDateFilter_ variable is correctly defined and applied in both measures. The date range calculation should be consistent.


    2. Measure Context: The context in which SumQuantityADJ and SumQuantity6Weeks are calculated might differ. Check if there are any additional filters or context changes affecting one measure but not the other.


    3. SUMMARIZECOLUMNS Function: Verify that the SUMMARIZECOLUMNS function is correctly applying the date filter. The date range should be consistent across all measures.

     

    4. I think you could also just use the following string of DAX code: 

    SumQuantity6Weeks_Debug =
    CALCULATE (
        SUM ( 'MaterialTransactions'[QuantityADJ_Positive] ),
        FILTER (
            'Calendar',
            'Calendar'[Date]
                >= DATEVALUE ( EndDate_ ) - WEEKDAY ( DATEVALUE ( EndDate_ ), 2 ) - ( 6 * 7 ) + 1
                && 'Calendar'[Date]
                    <= DATEVALUE ( EndDate_ ) - WEEKDAY ( DATEVALUE ( EndDate_ ), 1 ) + 1
        )
    )

     

    5. Also if possible I would like you to provide example data for further research.

     

     

    Best Regards

    Yilong Zhou

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