Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I have these variables
VAR ReportEndOfMonth = EOMONTH(DATE (YEAR(TODAY()), MONTH(TODAY()) -1, DAY(TODAY()) ), 0)
VAR ReportStartOfMonth = DATE (YEAR(ReportEndOfMonth), MONTH(ReportEndOfMonth) , DAY(1) )
ReportEndOfMonth gives me 31/07/2022, which is correct.
ReportStartOfMonth gives me 31/07/2022, which is wrong.
If I change ReportStartOfMonth to
VAR ReportStartOfMonth = DATE (YEAR(ReportEndOfMonth), MONTH(ReportEndOfMonth) , DAY(2) )
ReportStartOfMonth gives me 01/07/2022.
Ideas of what is going wrong?
Solved! Go to Solution.
Inside DAY(), there should be a date or replace it with 1 only (instead of DAY(1))
Regards,
Ritesh
Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users
DAX has its own DAY calculation:
DAY function (DAX) - DAX | Microsoft Docs
"Returns the day of the month, a number from 1 to 31."
To my understanding, you're feeding it DAY(1). The Serial codes are the same between Excel and PowerBI (e.g. 44617 = 25/02/2022).
What PowerBI is doing is taking this as [Serial Value 1] = 31/12/1899. That's returning DAY(31/12/1899) which returns the day of the month (31). This also explains why Serial Value 2 = 01/01/1900, and returns day of month (1).
A simple solution should be to amend your variable to this:
VAR ReportStartOfMonth = DATE (YEAR(ReportEndOfMonth), MONTH(ReportEndOfMonth) , 1 )
Inside DAY(), there should be a date or replace it with 1 only (instead of DAY(1))
Regards,
Ritesh
Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
111 | |
92 | |
84 | |
66 |