Forum Discussion

liran's avatar
liran
Frequent Visitor
8 years ago
Solved

sum or count a measure

hi,  i have a measure that calculate if a certain week is valid for each store and item when i put the weeks in the rows of my excel sheet i see the desirable result and every valid week gets...
  • OwenAuger's avatar
    OwenAuger
    8 years ago

    Thanks for that.

     

    It looks like the problem is the VAR/RETURN syntax.

    If you use VAR to store the result of your existing measure like this, it actually just evaluates once and locks in a single value, evaluated in the overall filter context  (i.e. not per week).

     

    We need the validobservation measure to be re-evaluated for every iteration of the SUMX, so the SUMX should refer to a measure (or equivalent expression wrapped in CALCULATE), not a variable.

     

    I would say the cleanest way to do this is to keep your first measure as you have defined it (since you know it's working at the Week level), and call it say validobservation.

     

    Then your new measure should be:

    Valid Week Count =
    SUMX ( 
        VALUES ( TimeTable[Week] ),
        [validobservation]
    )

    That is, the second argument of the SUMX should be a measure, not a variable.

     

    Does that help?

     

    Regards,

    Owen