Forum Discussion
PowerBI Dax
Hi,
This can be done in two steps:
1. Create a new table with the following code
Table = GENERATESERIES(1,12)Outcome:
2. Then create a new calculate column using the code:
Month Name = VAR n = 'Table'[Value] RETURN IF( n > 0 && n < 13 , -- THEN -- FORMAT(DATE(2022,n,1) ,"mmmm"), -- ELSE -- "Other" )Outcome:
If you want to go for shortcut, just have the names of the months in excel, and using 'Enter Data' have a new table in your power bi model.
As this is static, it is not going to change and make any difference.
5 Replies
- rohit_singh
Solution Sage
Hi Anonymous ,
Are you trying to create a table with a single column for months from Jan-Dec ? Something like, or something else ? Please share your expected output.
Kind regards,
Rohit- AnonymousNot applicable
Yes, exactly that so I can connect other tables and use the months in a slicer. Thanks
- rohit_singh
Solution Sage
Hi Anonymous ,
Thanks for your response. Since you've mentioned you already have a central date table, I assume it has a month field available. You can leverage that to create your new table.
If there is no month name on your date table, you can add a new column using your date column like
My date table is called dim_date
I simply create a new table summarizing the months column and I get a new table with only monthsMonths =SUMMARIZE(dim_date,dim_date[Month Name])
Please let me know if this works for you.Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊
- PC2790
Community Champion
This can be done in two steps:
1. Create a new table with the following code
Table = GENERATESERIES(1,12)Outcome:
2. Then create a new calculate column using the code:
Month Name = VAR n = 'Table'[Value] RETURN IF( n > 0 && n < 13 , -- THEN -- FORMAT(DATE(2022,n,1) ,"mmmm"), -- ELSE -- "Other" )Outcome:
If you want to go for shortcut, just have the names of the months in excel, and using 'Enter Data' have a new table in your power bi model.
As this is static, it is not going to change and make any difference.
- AnonymousNot applicable
Thank you 🙂