Forum Discussion
alihijazi
10 years agoHelper I
parameters
Hello I'm new to powerBI Is there a way to create a variable or parameter like vMaxYear = year(max(TrxDate)) and then use this parameter or variable in the filter of a calculate Dax expression?
Eric_Zhang
10 years agoMicrosoft Employee
You could declare a variable as below
LatestYearSumTotal =
VAR MaxYear = YEAR(max(Orders[OrderDate]))
RETURN
CALCULATE(
SUM(Orders[Freight]),FILTER(Orders,YEAR('Orders'[OrderDate])=MaxYear))