The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have monthly data for sales in format like
I want to calculate current month sales for each channel and previous month sales for each channel. I create a matrix with channel in rows and current month values in columns:
but strangely I can not reference the date column inside my measure:
CurrentMonthSales = CALCULATE(SUM('SalesTable'[Sales]),
FILTER('SalesTable', YEAR('SalesTable'[Date]) = YEAR(TODAY())),
FILTER ('SalesTable', MONTH('SalesTable'[Date] = MONTH(TODAY()))
))
Solved! Go to Solution.
Hey @darkmetrics ,
I do not understand what you mean by: "... I can not reference the date column inside my measure."
Nevertheless, I would write the measure like so:
CurrentMonthSales =
var __TODAY = TODAY()
var currentYear = YEAR( __TODAY )
var currentMonth = MONTH( __TODAY )
return
SUMX(
FILTER( 'SalesTable'
, YEAR('SalesTable'[Date]) = currentYear && MONTH('SalesTable'[Date] = currentMonth
)
, 'SalesTable'[Sales]
)
Hopefully, this helps what you are looking for.
Regards,
Tom
Hey @darkmetrics ,
I do not understand what you mean by: "... I can not reference the date column inside my measure."
Nevertheless, I would write the measure like so:
CurrentMonthSales =
var __TODAY = TODAY()
var currentYear = YEAR( __TODAY )
var currentMonth = MONTH( __TODAY )
return
SUMX(
FILTER( 'SalesTable'
, YEAR('SalesTable'[Date]) = currentYear && MONTH('SalesTable'[Date] = currentMonth
)
, 'SalesTable'[Sales]
)
Hopefully, this helps what you are looking for.
Regards,
Tom
Thank you, I will try