Forum Discussion
DAX
To get Previous month and current month as a new field.
Hi Guyz
I'm trying to create a custom column having "Current month" and "Previous month" as a tag based on the system date.
For example:- ( my system date is 27-06-2020 )
| Category | Date | Amount |
| A | 01-04-2020 | 100 |
| B | 01-04-2020 | 100 |
| C | 01-05-2020 | 100 |
| D | 02-05-2020 | 100 |
| E | 03-05-2020 | 100 |
| F | 04-05-2020 | 100 |
| G | 01-06-2020 | 100 |
| H | 02-06-2020 | 100 |
| I | 03-06-2020 | 100 |
| J | 04-06-2020 | 100 |
Expected result::-
| Category | Date | Amount | Flag |
| C | 01-05-2020 | 100 | Previous month |
| D | 02-05-2020 | 100 | Previous month |
| E | 03-05-2020 | 100 | Previous month |
| F | 04-05-2020 | 100 | Previous month |
| G | 01-06-2020 | 100 | Current month |
| H | 02-06-2020 | 100 | Current month |
| I | 03-06-2020 | 100 | Current month |
| J | 04-06-2020 | 100 | Current month |
Anonymous try this
Tag = IF ( EOMONTH ( Table[Date], 0 ) = EOMONTH ( TODAY(), -1 ), "Previous Month", IF ( EOMONTH ( Table[Date], 0 ) = EOMONTH ( TODAY(), 0 ), "Current Month", "" ) )I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
4 Replies
- parry2kSuper User
Anonymous try this
Tag = IF ( Table[Date] < EOMONTH ( TODAY(), -1 ) + 1, "Previous Month", IF ( EOMONTH ( Table[Date], 0 ) = EOMONTH ( TODAY(), 0 ), "Current Month", "Next Month" ) )I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- AnonymousNot applicable
Buddy, Thanks a ton !
I implemented the expression. However, April month is getting tagged as the previous month ( ideally it should not ).
Technically, April as Not consider ; May as Previous month and June as Current month
Please advise.- parry2kSuper User
Anonymous try this
Tag = IF ( EOMONTH ( Table[Date], 0 ) = EOMONTH ( TODAY(), -1 ), "Previous Month", IF ( EOMONTH ( Table[Date], 0 ) = EOMONTH ( TODAY(), 0 ), "Current Month", "" ) )I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- IceyCommunity Support
Hi Anonymous ,
Is this problem solved?
If it is solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.
If not, please let me know.
Best Regards,
Icey