Forum Discussion

Nigel99's avatar
Nigel99
Frequent Visitor
3 years ago
Solved

MTD Not Working Properly

Table:

DateItem
1-AugApple
1-AugOrange
1-AugBanana
2-AugApple
2-AugOrange
3-AugApple

 

There are 2 slicers:
Slicer1: Date: Single Selection
Slicer2: Item: Multiple Selection

DAX: To determine MTD count
TOTALMTD(COUNT(Table['Item']), DATEMTD(ALLSELECTED(Table['Date'])))

 

Case1: Slicer1: 2-Aug & Slicer2: Apple and Orange

DAX returns 4 (Correct)

 

Case2: Slicer1: 3-Aug & Slicer2: Apple and Orange

DAX returns 3. Expected output is 5. (3 Apples on 1/2/3Aug and 2 Oranges on 1/2Aug)

 

Seeking advice here as I am struggling hard throughout the day. How to get the MTD DAX to cater for 2 oranges in the past (1/2 Aug)?

  • Hi, Nigel99 

     

    You can try the following methods.
    New table:

    Date = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))

    Measure = Var _table=CALCULATETABLE(VALUES('Table'[Item]),FILTER('Table',[Item]<>BLANK()))
    Return
    CALCULATE(COUNT('Table'[Item]),FILTER(ALL('Table'),[Date]<=MAX('Date'[Date])&&[Item] in _table))

    Is this the result you expect?

     

    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.

     

6 Replies