Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
146 | |
108 | |
106 | |
90 | |
62 |