Forum Discussion
Create measure to return value from column when condition met for two other columns
- 4 months ago
Hi ck_ky,
If your measure is returning BLANK, it's often because the filter context isn't finding an exact row match between the two tables. Since your soil data is recorded every 5 minutes and the air data is hourly, the Date/Time fields likely don't line up perfectly.
Here are a few things to check:
- Ensure both tables use the same Date column datatype and format.
- One table might have full DateTime values, while the other only has Dates.
- Even a hidden time component can prevent a match.
- Try matching only on the Date part, not the full DateTime.
- Confirm that county names match exactly in both tables.
- Extra spaces or differences in capitalization can also result in BLANK values.
You can test with a simplified formula like this:
Min Daily Air Temp =
VAR _MinSoil =
MIN ( 'Soil.Temp'[Soil Surface Temperature (F)] )
VAR _Date =
CALCULATE (
MIN ( 'Soil.Temp'[Date] ),
FILTER (
'Soil.Temp',
'Soil.Temp'[Soil Surface Temperature (F)] = _MinSoil
)
)
VAR _County =
CALCULATE (
SELECTEDVALUE ( 'Soil.Temp'[County Name only] ),
FILTER (
'Soil.Temp',
'Soil.Temp'[Soil Surface Temperature (F)] = _MinSoil
)
)
RETURN
CALCULATE (
MIN ( 'NASA Power Weather Data'[MinTempF] ),
FILTER (
'NASA Power Weather Data',
'NASA Power Weather Data'[County Name only] = _County
&& DATEVALUE ( 'NASA Power Weather Data'[Date] ) = DATEVALUE ( _Date )
)
)If you still get BLANK, try creating a temporary table visual displaying:
- Soil Temp Date
- Air Temp Date
- County from both tables
- The calculated variables
This can help pinpoint which field isn't matching between the tables.
Thank you.
- Ensure both tables use the same Date column datatype and format.
Use CALCULATE with explicit filters on both County and Date instead of LOOKUPVALUE:
Min Daily Air Temp for Minimum Surface Temperature =
VAR _MinSurf =
MIN ( 'Soil.Temp'[Soil Surface Temperature (F)] )
VAR _MinSurfDate =
CALCULATE (
SELECTEDVALUE ( 'Soil.Temp'[Date] ),
'Soil.Temp'[Soil Surface Temperature (F)] = _MinSurf
)
VAR _MinSurfCounty =
CALCULATE (
SELECTEDVALUE ( 'Soil.Temp'[County Name only] ),
'Soil.Temp'[Soil Surface Temperature (F)] = _MinSurf
)
RETURN
CALCULATE (
MIN ( 'NASA Power Weather Data'[MinTempF] ),
'NASA Power Weather Data'[County Name only] = _MinSurfCounty,
'NASA Power Weather Data'[Date] = _MinSurfDate
)Thank you for this suggestion.
However, I am still getting "BLANK" for the card.
Is there something with my data that may be causing this?