The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I am having an issue today with a DAX formula.
The scenario is as follows. I have 2 Power BI desktop files which are formatted identically. I have them linked to separate Excel workbooks which are formatted identically. I am inserting a calculated column into both datasets under "Modeling" in Power BI with the following formula:
Week_Crctd = if(weeknum('Line Calls'[Date])<=52,(weeknum('Line Calls'[Date])),1)
In one PBI desktop file, I receive the expected result; a whole number between 1 and 52 which varies correctly according to the [Date] value. In the other file, I receive the following error:
As I mentioned before, both Excel files are formatted with the exact same number formatting in these columns and both PBI desktop files are formatted with the same Data Type, Format, Data Category, and Default Summarization. What gives?
Thanks guys and gals
Solved! Go to Solution.
Thanks for the input everyone.
However, after going through my source data, I found the following string of typos in the date column. Correcting them also corrected this issue.
381 1/19/16 382 1/19/16 383 1/19/16 384 1/19/16 385 1/19/16 386 1/19/16 387 01/119 388 01/119 389 01/119 390 01/119
I have adjusted the data validation and formatting restrictions to the user form through which this data is input.
Thanks again for helping with my case of the Mondays.
That's a real zinger.
It took me a little while to reproduce. I can reliably get that behavior for any date < 1899-12-30. That is the 0-date in the Tabular engine, and my guess is that someone didn't handle negative values appropriately in the function definition. I can bounce up against the upper date boundary without errors.
Do you have data with dates < 1899-12-30?
**Edit:**
Power Query does not suffer from a similar error, and Date.WeekOfYear() is functional in the full range from 0001-01-01 through 9999-12-31. DAX Can't handle dates as small as 0001-01-01, so you should be good to do this sort of transformation in Power Query. Generally it's a better practice to do transformations before importing to the data model, anyway, to take advantage of better compression.
**Edit2:**
The error reported in the original post seems to be unique to <1899-12-30 dates. If I input malformed dates or text strings I get
Cannot convert value '4' of type Text to type Date.
Thanks for the input everyone.
However, after going through my source data, I found the following string of typos in the date column. Correcting them also corrected this issue.
381 1/19/16 382 1/19/16 383 1/19/16 384 1/19/16 385 1/19/16 386 1/19/16 387 01/119 388 01/119 389 01/119 390 01/119
I have adjusted the data validation and formatting restrictions to the user form through which this data is input.
Thanks again for helping with my case of the Mondays.
@Greg_Deckler, the 0-date in Tabular is 1899-12-30, not 1900-01-01. This is actually inconsistent with both Excel and SQL Server.
As you can see below, I've created a table with the integer values -1, 0, and 1. I then change the data type to Date, and I get back 1899-12-29, 1899-12-30, and 1899-12-31. The misbehavior starts for anything with a negative offset from the 0-date.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
80 | |
77 | |
43 | |
39 |
User | Count |
---|---|
150 | |
116 | |
66 | |
64 | |
55 |