Tyler Bradley
month = STARTOFMONTH(orders_small[date])
sum_amount = SUM(orders_small[dollar_amount])
distinct_months = DISTINCTCOUNT(orders_small[month])
monthly_average = DIVIDE([sum_amount], [distinct_months])
sum_amount_zero = SUM(orders_small[dollar_amount]) + 0
monthly_average = DIVIDE([sum_amount], 12)
cal_table = CALENDAR(
DATE(2020, 01, 01),
DATE(2020, 12, 31))
cal_table = CALENDAR(
DATE(YEAR(TODAY()) - 1, 01, 01),
DATE(YEAR(TODAY()) - 1, 12, 31))
cal_table = CALENDAR(
MIN(orders_big[date]),
MAX(orders_big[date]))
cal_month = STARTOFMONTH(cal_table[DATE])
product = SUMMARIZECOLUMNS(orders_big[product])
customer = SUMMARIZECOLUMNS(orders_big[customer_id])
cal_table[cal_month], 'product'[product]
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount])
orders_zeros_added =
ADDMISSINGITEMS(cal_table[cal_month], 'product'[product],
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount])),
cal_table[cal_month], 'product'[product])
orders_zeros_added =
CALCULATETABLE(ADDCOLUMNS(
ADDMISSINGITEMS(cal_table[cal_month], 'product'[product],
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount])),
cal_table[cal_month], 'product'[product]),
"amount filled", IF(ISBLANK([amount]), 0, [amount])))
product_availability =
FILTER(CROSSJOIN(cal_table, product),
cal_month[month] >= product_dates[start_month] &&
cal_month[month] <= product_dates[end_month])
orders_zeros_added =
ADDMISSINGITEMS(cal_table[cal_month], 'product'[product],
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount])),
cal_table[cal_month], 'product'[product])
orders_zeros_added =
ADDMISSINGITEMS(cal_table[cal_month], 'product'[product],
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount])),
cal_table[cal_month], 'product'[product], product_availability)
orders_zeros_added = CALCULATETABLE(ADDCOLUMNS(
ADDMISSINGITEMS(cal_table[cal_month], 'product'[product],
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount])),
cal_table[cal_month], 'product'[product], product_availability),
"amount filled", IF(ISBLANK([amount]), 0, [amount])))
product_zeros = SUMMARIZECOLUMNS(orders_big[product])
cal_table_month =
var CalendarDates =
GENERATE( CALENDAR(DATE(2020, 01, 01),
DATE(2020, 12, 31)),
ROW("month", DATE(YEAR( [Date] ), MONTH( [Date] ), 01)))
return
SUMMARIZE(CalendarDates, [month])
product_availability = FILTER(
CROSSJOIN(cal_table_month, product_dates),
cal_table_month[month] >= product_dates[start_month] &&
cal_table_month[month] <= product_dates[end_month])
available = LOOKUPVALUE(product_availability[product],
product_availability[month], orders_zeros_added[cal_month],
product_availability[product], orders_zeros_added[product])
amount_filled_missing = IF(ISBLANK(orders_zeros_added[available]),
BLANK(), orders_zeros_added[amount filled])
1 - (A/B) = (B/B) - (A/B) = (B - A)/B
orders_zeros_added =
CALCULATETABLE(ADDCOLUMNS(
ADDMISSINGITEMS(cal_table[cal_month], 'product'[product],
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount]),
"customers", DISTINCTCOUNT(orders_big[customer_id])),
cal_table[cal_month], 'product'[product], product_availability),
"amount filled", IF(ISBLANK([amount]), 0, [amount]),
"customers filled", IF(ISBLANK([customers]), 0, [customers])))
orders_zeros_added =
CALCULATETABLE(ADDCOLUMNS(
ADDMISSINGITEMS(cal_table[cal_month], 'product'[product],
SUMMARIZECOLUMNS(cal_table[cal_month], 'product'[product],
"amount", SUM(orders_big[dollar_amount]),
"customers", DISTINCTCOUNT(orders_big[customer_id]),
"orders", DISTINCTCOUNT(orders_big[order_number])),
cal_table[cal_month], 'product'[product], product_availability),
"amount filled", IF(ISBLANK([amount]), 0, [amount]),
"customers filled", IF(ISBLANK([customers]), 0, [customers]),
"orders filled", IF(ISBLANK([orders]), 0, [orders])))