Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
erhan_79
Post Prodigy
Post Prodigy

Status Of Month Calculating Error

Hi there ;

 

i have a calculation on power quaery side with a M formula 

 

it works like that   ; i have date column and i am creating status column based on that dates.

 

Rule :

if the date's month before the current month status = Previous Month 

İf the date's month is in current month status =Actual Month

İf the dates's month is after current month status = Next Month 

 

So all dates before the current month are Previous and all dates after the current month are Next Month , all the dates in current month are  Actual Month 

 

i am using below formula on power Query side and i need this formula on power query side : 

 

Custom = if Date.EndOfMonth([File Date]) = Date.EndOfMonth(Date.From(DateTime.FixedLocalNow())) then "Actual Month" else if Date.EndOfMonth([File Date]) <= Date.AddMonths( Date.EndOfMonth(Date.From(DateTime.FixedLocalNow())),-1) then "Previous Month" else if Date.EndOfMonth([File Date]) >= Date.AddMonths( Date.EndOfMonth(Date.From(DateTime.FixedLocalNow())),+1) then "Next Month" else null

 

but as you see below  when i use like that formula for august month system gives "null" ,  how can i solve this problem could you check pls

 

cap.JPG

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@erhan_79 , seems fine try like

Custom = if Date.EndOfMonth([File Date]) = Date.EndOfMonth(Date.From(DateTime.FixedLocalNow())) then "Actual Month"
else if Date.EndOfMonth([File Date]) <= Date.EndOfMonth(Date.AddMonths( Date.From(DateTime.FixedLocalNow()),-1)) then "Previous Month" else if Date.EndOfMonth([File Date]) >= Date.AddMonths( Date.EndOfMonth(Date.From(DateTime.FixedLocalNow())),+1) then "Next Month" else null

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@erhan_79 , seems fine try like

Custom = if Date.EndOfMonth([File Date]) = Date.EndOfMonth(Date.From(DateTime.FixedLocalNow())) then "Actual Month"
else if Date.EndOfMonth([File Date]) <= Date.EndOfMonth(Date.AddMonths( Date.From(DateTime.FixedLocalNow()),-1)) then "Previous Month" else if Date.EndOfMonth([File Date]) >= Date.AddMonths( Date.EndOfMonth(Date.From(DateTime.FixedLocalNow())),+1) then "Next Month" else null

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

thank you very much @amitchandak !

 

it is working now 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.