Forum Discussion
Retrieve value same date current year
- 9 years ago
Hi Anonymous,
You can use a column or a measure, taking into account that the column value will ocupy space in your model and the best practices for the DAX usage is to make a measure if possible and don't use calculated columns below you have the formula for the measure:
Value_Date = VAR date_select = MIN ( GasUsagePerDegreeDay[Date] ) RETURN CALCULATE ( SUM ( GasUsagePerDegreeDay[WeightedDegreeDays] ), Table1[Date] = DATE ( YEAR ( NOW () ), MONTH ( date_select ), DAY ( date_select ) ) )However if you want to do it in a column the formula should be this one:
Value_Date_ = VAR date_lookup = Table1[Date] RETURN LOOKUPVALUE ( GasUsagePerDegreeDay[WeightedDegreeDays], GasUsagePerDegreeDay[Date], DATE ( YEAR ( NOW () ), MONTH ( date_lookup ), DAY ( date_lookup ) ) )Regards,
MFelix
Hmmm, definitely seems like a valid solution... but if I try it, it returns the following error message:
Anonymous,
As I can see from the error the problem comes from your first measure CorrectGasUsage what kinfd of information are you calculating in this measure.
MFelix
- Anonymous9 years agoNot applicable
Yeah, it's the measure we started with:
WeightedDegreeDays SDCY = VAR date_select = MIN ( GasUsagePerDegreeDay[Date] ) RETURN CALCULATE ( SUM ( GasUsagePerDegreeDay[WeightedDegreeDays] ), GasUsagePerDegreeDay[Date] = DATE ( YEAR ( NOW () ), MONTH ( date_select ), DAY ( date_select ) ) )So it returns the DegreeDays (an energy-technical term relating weather and gas usage) of the same day and month, but for the current year.
- MFelix9 years agoSuper User
If you place this measure in one visual everything is ok?
Is it possible to share a sample of PBIX file?
Regards,
MFelix