Forum Discussion

Silvie's avatar
Silvie
Helper I
2 years ago
Solved

MAT calculation wrong

Hi,    I posted this on Saturday as a reply on an existing topic, but didn't get any answer yet. That's why I'm creating a new message.  I'm new at calculating rather complex formulas. I need to c...
  • lbendlin's avatar
    lbendlin
    2 years ago

    Your data model looks reasonable. Personally I would merge the Periode Type data into the Calendar table (like you did in the Periode Dimensies OLD.

     

    You must use &&  , not  ||  

     

    You must use the date from the calendar table, not from the fact table

     

    % Nutriscore MAT = 
    var d = max('Calendar'[Date])
    var a = filter(ALLSELECTED(Nutriscore),Nutriscore[Date]<=d && Nutriscore[Date]>EDATE(d,-12))
    return if (countrows(a)=12,divide(sumx(a,Nutriscore[OOP Nutriscore A-B]),sumx(a,Nutriscore[OOP Nutriscore]),0))