The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
User | Count |
---|---|
29 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
36 | |
14 | |
12 | |
7 | |
7 |