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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MayAnk__Rathi
Helper I
Helper I

Issue in applying If & Or function

I face issue in implementing a formula in power query

Formula is: If date in Column A is equal to today's date or yesterday's date or tomorrow's date then result is T else F.

Please guide me.

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@MayAnk__Rathi Open your Power Query editor.
Add a new custom column.
Use the following formula in the custom column:

let
Today = Date.From(DateTime.LocalNow()),
Yesterday = Date.AddDays(Today, -1),
Tomorrow = Date.AddDays(Today, 1)
in
if [ColumnA] = Today or [ColumnA] = Yesterday or [ColumnA] = Tomorrow then "T" else "F"




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

6 REPLIES 6
v-sgandrathi
Community Support
Community Support

Hi @MayAnk__Rathi,

 

Thank you @bhanu_gautam for the response to the query.

 

I'm glad you found a solution and resloved  the query. Kindly mark the useful reply as the accepted solution so that others  in the community can find it quickly.

 

Thankyou for connecting with Microsoft Community Forum.

Omid_Motamedise
Super User
Super User

Hi @MayAnk__Rathi 

 

use the following formula

let
    today = Date.From(DateTime.LocalNow()),
    value = [Column A],
    result = if value = today or value = Date.AddDays(today, -1) or value = Date.AddDays(today, 1) then "T" else "F"
in
    result
If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
slorin
Super User
Super User

Hi @MayAnk__Rathi 

 

if Number.Abs(Number.From(Date.From(DateTime.LocalNow())-[ColumnA]))<=1 then "T" else "F"

Stéphane 

abdelazizallam0
New Member

let
Source = Excel.CurrentWorkbook(){[Name="Table1_2"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let
today = Date.From(DateTime.LocalNow()),
yesterday = Date.AddDays(today, -1),
tomorrow = Date.AddDays(today, 1)
in
if [date] = today or [date] = yesterday or [date] = tomorrow then "T" else "F")
in
#"Added Custom"

bhanu_gautam
Super User
Super User

@MayAnk__Rathi Open your Power Query editor.
Add a new custom column.
Use the following formula in the custom column:

let
Today = Date.From(DateTime.LocalNow()),
Yesterday = Date.AddDays(Today, -1),
Tomorrow = Date.AddDays(Today, 1)
in
if [ColumnA] = Today or [ColumnA] = Yesterday or [ColumnA] = Tomorrow then "T" else "F"




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






yes, now formula is working.

 

Thanks 👍👍

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Kudoed Authors