Forum Discussion
Issues with measure using time intelligence
- 8 years ago
How about this one
Total Amount Last Year = CALCULATE ( [Total Amount], SAMEPERIODLASTYEAR ( 'Dates'[Date] ), ALL ( Dates ) )
Hi,
You've built the wrong relationship. In the transactions table, create this calculated column formula
=DATE(LEFT(Transactions[date_key],4),MID(Transactions[date_key],5,2),RIGHT(Transactions[date_key],2))
Edit your relationship to know connect this Date column to the Date column in the Dates Table.
Just do this much and your measure will work without any editing.
Hope this helps.
Hi Ashish_Mathur,
This also works, although like the inclusion of the optional ALL(Dates) filter, I don't understand why this step is required.
Usually, using a date key of format YYYYMMDD is the recommended practice for a datawarehouse. Is there some sort of limitation in Power BI for date relationships where it needs to be an actual date field instead of a surrogate key of format YYYYMMDD?
- Ashish_Mathur8 years agoSuper User
Hi,
PowerBI's data and time intelligence functions only work with actual date entries. Which is why your formula (without any editing) started working when i converted a text entry into a Date and then built the relatiosnhip.