'DAX Iterator Behavior

I don't think this is doing what I want it to do. I have a fact table with columns date, weekstarting, customer, product and qtyshipped and I want an average product sales including dates with 0 sales. The 0 sales dates don't exist in the table. If I use an iterator does this do what I think its doing? I've grouped by week.

AVERAGEX(VALUES(facttable[weekstarting]),SUM(fact[qtyshipped]))

If this doesn't work this way is there a way to make a measure that would account for these 0s without editing the fact table? I can't seem to find a function that would do this.



Solution 1:[1]

It'd just bypass the average function and use a SUM and divide by DATEDIFF set to days, weeks or what ever you want the average of.

DIVIDE(
    SUM( fact[qtyshipped] ),
    DATEDIFF(
        facttable[weekstarting],
        facttable[weekending],
        WEEK
    )
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daniel A. Gregersen