The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi guys,
i am trying to return the month name from a date
formula for testing I wrote is
Solved! Go to Solution.
Hello @IanCockcroft
You don't actually need to call the month for formatting your date the way want, you can just use
dispPevMnthScenario = FORMAT ( LASTDATE ( calender[PK_Date] ) , "m/d/yyyy-mmm" )
The reason you are seeing Jan in your string is because you used MONTH in your formula.
The MONTH of 2/28/2019 is 2
PowerBI sees numbers as a date so when you format 2 as MMM it converts 2 to a date of 1/1/1900 then gives you the mmm of that date which is Jan. Here is an image showing both:
It seems to be a filter issue. DAX doesnt give wrong answers, it sometimes gives suprising answers, but there is always a reason. Can you upload a sample?
@IanCockcroft Are you adding this as a column? If yes then you don't need to use LASTDATE function. use following if adding as a column
Month = FORMAT ( calender[PK_Date] , "m/d/yyyy-mmm" )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi parry2k, its actually for a dynamic label within a card. Once I get this right, i will have 2 labelS, 1 for current name of year and month and one for previous name of year and month. The actual vallues for these 2 are measures in a matrix with the column header removed.
Because it needs to return a single value, I added LASTDATE to illmintae all the other dates.
Thanks for taking the time to have a look.
cheers
Ian
Hello @IanCockcroft
You don't actually need to call the month for formatting your date the way want, you can just use
dispPevMnthScenario = FORMAT ( LASTDATE ( calender[PK_Date] ) , "m/d/yyyy-mmm" )
The reason you are seeing Jan in your string is because you used MONTH in your formula.
The MONTH of 2/28/2019 is 2
PowerBI sees numbers as a date so when you format 2 as MMM it converts 2 to a date of 1/1/1900 then gives you the mmm of that date which is Jan. Here is an image showing both:
Thanks jdbuchanan71.
The final measure code is
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 June 2024 Power BI update to learn about new features.
User | Count |
---|---|
99 | |
93 | |
81 | |
63 | |
56 |
User | Count |
---|---|
248 | |
124 | |
111 | |
78 | |
78 |