Forum Discussion
Percentage calculation
- 5 years ago
Not clear if you have a Date table or not, but the approach is similar. Basically, you need to harvest the min/max dates selected in your slicer, calculate two variables (one for each), and then do the math. Here is an example that assumes you have a single table with all your data.
Pct Change =
VAR vStartDate =
MIN ( Table[Date] )
VAR vEndDate =
MAX ( Table[Date] )
VAR vStartPrice =
CALCULATE (
MIN ( Table[Close] ),
Table[Date] = vStartDate
)
VAR vEndPrice =
CALCULATE (
MIN ( Table[Close] ),
Table[Date] = vEndDate
)
RETURN
DIVIDE (
vEndPrice - vStartPrice,
vStartPrice
)Regards,
Pat
- 5 years ago
Anonymous , prefer to use a date table
diff between selected range =
var _max = maxx(allselected('Date'),'Date'[Date])
var _min = minx(allselected('Date'),'Date'[Date])
return
divide(calculate(max(table[close price]), filter('Date', 'Date'[Date] =_max)),calculate(max(table[close price]), filter('Date', 'Date'[Date] =_min)))-1To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
Anonymous , prefer to use a date table
diff between selected range =
var _max = maxx(allselected('Date'),'Date'[Date])
var _min = minx(allselected('Date'),'Date'[Date])
return
divide(calculate(max(table[close price]), filter('Date', 'Date'[Date] =_max)),calculate(max(table[close price]), filter('Date', 'Date'[Date] =_min)))-1
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.