Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Dear all,
I´m trying a "simple" measure to calculate the cumulative values from the beginning of the year until a month from the most recent date.
For example, In FactSales table I have column OrderDate where the last date is 2020.07.30
The formula below works:
Sum Of Sales Amount YTD =
VAR max_month = 7
RETURN
TOTALYTD(
[Sum Of SalesAmount],
DimDate[Date],
MONTH(FactSales[OrderDate]) <= max_month
)
but this formula does not work:
Sum Of Sales Amount YTD =
VAR max_month = MONTH(MAX(FactSales[OrderDate]))
RETURN
TOTALYTD(
[Sum Of SalesAmount],
DimDate[Date],
MONTH(FactSales[OrderDate]) <= max_month
)
Any help?
Solved! Go to Solution.
@Lukasz004 , You have try like example
YTD=
var _max = maxx(allselected('order'),'order'[order date])
var _min = date(year(_max ),1,1)
return
CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _max) )
or
YTD=
var _max = maxx(allselected('order'),'order'[order date])
var _min = date(year(_max ),1,1)
return
CALCULATE(sum('order'[Qty]), FILTER(('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _max) )
@Lukasz004 , You have try like example
YTD=
var _max = maxx(allselected('order'),'order'[order date])
var _min = date(year(_max ),1,1)
return
CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _max) )
or
YTD=
var _max = maxx(allselected('order'),'order'[order date])
var _min = date(year(_max ),1,1)
return
CALCULATE(sum('order'[Qty]), FILTER(('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _max) )
I changed my variable:
VAR max_month = MONTH(MAX(FactSales[OrderDate]))
to
VAR max_month = MONTH(MAXX(ALL(FactSales), FactSales[OrderDate]))
and the formula works fine 😉
Thanks for your help @amitchandak
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
146 | |
87 | |
66 | |
52 | |
46 |
User | Count |
---|---|
215 | |
90 | |
83 | |
66 | |
58 |