Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi ,
Im using this for current month and year which is working fine.
currentdate=(Date.ToText(DateTime.Date(DateTime.LocalNow()),"MMyyyy"))
Output is =112022
now i want to get prevoius month
Pdate=(Date.ToText(DateTime.Date(DateTime.LocalNow()),"MMyyyy")) -1
but its not working please advise.
Solved! Go to Solution.
Hi @faheem_Latif_BI ,
Please try below mquery code in custom column:-
Text.PadStart(Text.From(Date.Month(DateTime.LocalNow())-1),2,"0")&Text.From(Date.Year(DateTime.LocalNow()))
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Pdate=Date.ToText(Date.AddMonths(DateTime.Date(DateTime.LocalNow()),-1),"MMyyyy"))
Thanks for reply im using like this but giving me error
Table.AddColumn(#"Added Custom", "Previous_MonthYear", each Date.ToText(Text.PadStart(Text.From(Date.Month(DateTime.LocalNow())-1),2,"0")&Text.From(Date.Year(DateTime.LocalNow())),"MMyyyy"))
Could you please share the error?
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
@faheem_Latif_BI Please try this:-
#"Added Custom" = Table.AddColumn(#"Added Custom", "Previous_MonthYear", each Text.PadStart( Text.From(Date.Month(DateTime.LocalNow())-1),2,"0")&Text.From(Date.Year(DateTime.LocalNow())))
in
#"Added Custom"
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
smart 18
UR star
Hi @faheem_Latif_BI ,
Please try below mquery code in custom column:-
Text.PadStart(Text.From(Date.Month(DateTime.LocalNow())-1),2,"0")&Text.From(Date.Year(DateTime.LocalNow()))
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 6 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 15 | |
| 8 | |
| 8 | |
| 8 |