Forum Discussion
Transformation : Last Month Flag
Hi,
I am trying to make flag of Last month,but unable to do so. How can i create a column with flag T/F against Last month
| S.NO | User | Date |
| 1 | A1 | 1-Jun-20 |
| 2 | A2 | 19-Jul-20 |
| 3 | a3 | 12-Jul-20 |
Out put should be like :
| S.NO | User | Date | Flag |
| 1 | A1 | 1-Jun-20 | N |
| 2 | A2 | 19-Jul-20 | Y |
| 3 | a3 | 12-Jul-20 | Y |
3 Replies
- FarhanAhmed
Community Champion
What exactly you are trying to achieve? If you are trying to calculate some values based on last month you can do it by using TimeIntelligence functions.
https://docs.microsoft.com/en-us/dax/time-intelligence-functions-dax
- amitchandak
Super User
Anonymous , In case you need a column with last month value to take a call use a formula like
countx(filter(Table, table[User] =earlier(table[User] ) && eomonth(table[date],0) =eomonth(earlier(table[date]),-1)),table[S.NO])
For a Measure : https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
- v-zhenbw-msft
Community Support
Hi Anonymous ,
Do you want to add a column to distinguish the last month and current month?
If yes, you can refer the following formula.
Flag = var _current_month = MONTH(TODAY()) var _month = MONTH('Table'[Date]) return IF( _month=_current_month, "Y", IF( _month=_current_month-1, "N","Other" ) )If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.