Forum Discussion

newgirl's avatar
newgirl
Icon for Post Patron rankPost Patron
6 years ago
Solved

Complicated DAX using SUMX

Hi! I hope somebody can help me with my problem.    I have this file that I'm trying to figure out why the numbers are changing just by refreshing the data. Sadly, this file was just passed on from...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Actually, you should ignore all my posts. The formula written by the developer is good. There is no error in it.

     

    Earlier, I overlooked one point. It is in the following line of code.

     

    CROSSFILTER ( 'Calendar'[Date], fTMS[date_backinplant], NONE )

     

    The explanation is, there is a relationship between "Calendar[Date]" field to "ftms[date_backinplant]" field. So when you plot the measure to a matrix with "Calendar[Date]" on columns and "fmts[RealPlate]" on the rows, these two fields filter the fTMS table and as a result, only those records with "date_backinplant" and "realplate" has records on any given date is passed on to the calculation. But you need the "24 Hours" for all the dates betwen "date_inline" and "date_backinplant". To do this, the filter from "Calendar[Date]" field on "ftms[date_backinplant]" had to be removed.  It was done using CROSSFILTER() function with "NONE" as the 3rd paramenter which removes the filter from "Calendar[Date]" on fTMS table.

     

    All is perfect till now. But the problem arised when you had the following record in your data.

     

    DTSStagetime_inlinetime_backinplantdate_inlinedate_backinplantRealPlate
    COMPLETED02:00:0021:24:0006-03-202008-06-2020ABC335

     

    In this record, the date_backinplant has a value of 6th Jun, but date_inline has a value of 6th Mar, and because of the CROSSFILTER with "NONE" as the parameter, this record was not filtered out although date_backinplant's 6th Jun date falls outside your date selection. Therefore, from 6th Mar 2020 onwards, for every day, the formula inserted 24 Hours till the last day in your matrix which is 29th March 2020.

     

    If you want to omit the records with "date_backinplant" falling outside the range of your selected date range, you will have to exclusively add a filter to your fTMS table in the code somewhere near the filter on "COMPLETED" stage.