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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Need help on Calculation with Calculated columns

Hi All,

I need your support in resolving the logic and syntax please:

 

Logic: The calculated RTdate is 3aDate minus 4 weeks (omit any records with 3aDate blank)
I have created a column in power query:
Syntax used: RTDate=Date.AddDays([3aDate] ,-28) , but not sure how to omit that blank record

*********************

With the cretaed RTDate column, i have created column (RStatus) in data tab with the below logic for a,b &c

Logic:

a.Overdue --->if actual_date is blank and the current date is later than the RTdate
b. 4Due --->if actual_date is blank and the current date is later than 4 weeks before RTdate
c. onTime---> if actual_date is on or before RTdate

Syntax used:
RStatus =if([actual_date]=BLANK() && NOW()>[RTdate],"Overdue",
if([actual_date]=BLANK() && NOW()>DATEADD([RTdate],-28,DAY),"4Due",
if([actual_date]=TODAY() || ([actual_date]<([RTdate])) ,"onTime", "")))

 

When i used the above column(RStatus) to pull in visual and could notice there was issue with the logic.
Your help is much appreciated!!!

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

DATEADD function expects a date column as the first parameter rather than a date value. You can add integers (positive and negative) to a date directly to get a date that many days after or before the date. Try DAX

RStatus =
IF (
    ISBLANK ( [actual_date] ),
    IF ( NOW () > [RTdate], "Overdue", IF ( NOW () > [RTdate] - 28, "4Due" ) ),
    IF ( [actual_date] <= [RTdate], "onTime", "" )
)

 

And when you created a column in power query, what do you mean to omit that blank record? When a date value is null, Date.AddDays will return null too.

080204.jpg

 

Let me know if you still have questions. Sample data is appreciated to help make the expected result easier to understand.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

Greg_Deckler
Community Champion
Community Champion

@Anonymous I would recommend converting to a SWITCH(TRUE(),...) statement as this tends ot make the logic much more obvious and easily handled. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors