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.
Hi everyone,
I am struggling to create a custom column to indicate "Previous Month" for my Date Table.
I've come as far as creating a Current Month with a custom column in M-code:
if [Date] >= [Start_Of_This_Month] and [Date] <= [#"End_Of_Current_Month "] then 1 else 0
Here's a Dropbox link (https://www.dropbox.com/sh/r5fe8i7ej720jnn/AADsipGqJ1f1F7J7O4QZUoPTa?dl=0) to the PBIX file with the Calendar I need help with, if someone can either direct me in the right direction or edit my template that would be much appreciated.
The end Result should be one column with 3 options(In text);
"Current Month" = Current Month to Current Month End of Month (ex 01June - 30 June)
"Previous Month" = Previous month, StartOfMonth - Previous Month, EndOfMonth (ex 01 May- 31May)
"Historical" = All dates prior to "Previous Month"
If it is easier in DAX that should also be fine as long as I can have a slicer on my Report PAge view To select those 3 options in one slicer.
In DAX I have a MTD/QTD/YTD Multiple selection which might also be the way to go to achieve above mentioned.
Here is the code to edit if needed
Thank you in advance to anyone willing to help 🙂
Solved! Go to Solution.
Not very clear. Try a new column
Month Type = Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1*month(Today())),"Last year Last Month" ,
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY")
)
Not very clear. Try a new column
Month Type = Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1*month(Today())),"Last year Last Month" ,
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY")
)
@amitchandakthank you sir, that worked 100%. Thank you for your response I appreciate it.
Do you mind showing me how to do this in PQ to broaden my understanding based on columns in Date Dimension below?
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 |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |