March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi!
I am trying to pull what the min temp was last year for a specifc date. I have a dates table that is just an extended date table, a weather history table that contains previous year info, and a forecast table to contains the forecast for the next 7 days.
I am trying to pull what the min temp was last year for the forecasted 7 days. I tied the below measure but it didnt pull anything. Any ideas on how i might be able to do this pleasE?
Solved! Go to Solution.
You're facing this error because the DATEADD function in DAX expects the first argument to be a column reference, not a scalar value like a measure.
We need to adjust the approach very slightly by using "EDATE".
The main reason for using EDATE is that it directly works with scalar values and allows you to easily manipulate dates by a specific number of months.
If this post helps, then please consider "Accept it as the solution" to help the other members find it more quickly.
Hi @ebrownretail- create a measure to get the minimum temperature from the previous year for the forecasted 7 days
create two measures to get the start and end dates of the forecast period
Forecast Start Date = MIN('Forecast Table'[Date])
Forecast End Date = MAX('Forecast Table'[Date])
use the above two measure in your main measure to get the min temp for the same period last year
Min Temp Last Year =
VAR ForecastStart = [Forecast Start Date]
VAR ForecastEnd = [Forecast End Date]
VAR MinTempLastYear =
CALCULATE(
MIN('Weather History'[MinTemp]),
FILTER(
'Weather History',
'Weather History'[Date] >= DATEADD(ForecastStart, -1, YEAR) &&
'Weather History'[Date] <= DATEADD(ForecastEnd, -1, YEAR)
)
)
RETURN
MinTempLastYear
Hope it helps.
Proud to be a Super User! | |
thank you. I just tried this and i get the below error. It would not let me enter the date var in the DATEADD.
The first argument to 'DATEADD' must specify a column.
You're facing this error because the DATEADD function in DAX expects the first argument to be a column reference, not a scalar value like a measure.
We need to adjust the approach very slightly by using "EDATE".
The main reason for using EDATE is that it directly works with scalar values and allows you to easily manipulate dates by a specific number of months.
If this post helps, then please consider "Accept it as the solution" to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
115 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
167 | |
117 | |
63 | |
57 | |
50 |