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
Ramendra
Helper IV
Helper IV

Power query expression for below excel formula

Can someone please help with power query expression for below excel formula.

Where Extract date is the date column and A:A is the same date column in excel.

I need correct expression for Power query only.

I am using custom week dates which start from Wednesday to next Tuesday.


=IF([@[Extract Date]]=MAX(A:A),"Current Week",IF([@[Extract Date]]=(MAX(A:A)-7),"Last Week"))

1 ACCEPTED SOLUTION

Hi,  @Ramendra 

Use  Date.AddDays([Extract Date],-3)  to replace [Extract Date].

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc6xEYAgEADBXoidgT8EoRaG/tvATC/cbNdKFCKPHKR9farSLTWpS480pPkXRQpJF3RBF3RBF3RBF97LPg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Extract Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Extract Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Date.IsInCurrentWeek(Date.AddDays([Extract Date],-3)) then "This Week" else if Date.IsInPreviousWeek(Date.AddDays([Extract Date],-3)) then "Last Week" else "Other week")
in
    #"Added Custom"

77.png

Best Regards,
Community Support Team _ Eason

 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Ramendra , In power query you have function

Date.IsInCurrentWeek ,Date.IsInPreviousWeek

 

if Date.IsInCurrentWeek([Date]) then "This Week" else

if Date.IsInPreviousWeek([Date] then "Last Week" else "Other week"

end

 

 

refer: Power BI Tutorial Series for Beginners: Date.IsInCurrentWeek, Date.IsInNextWeek, Date.IsInPreviousWeek: https://www.youtube.com/watch?v=HgrG9I51Nbk 

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

Hi @amitchandak ,

 

Sorry but I am using custom week which start from Wednesday to next Tuesday

But this formula will take standard week only.
Please correct me if I am wrong?

Hi,  @Ramendra 

Use  Date.AddDays([Extract Date],-3)  to replace [Extract Date].

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Vc6xEYAgEADBXoidgT8EoRaG/tvATC/cbNdKFCKPHKR9farSLTWpS480pPkXRQpJF3RBF3RBF3RBF97LPg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Extract Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Extract Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Date.IsInCurrentWeek(Date.AddDays([Extract Date],-3)) then "This Week" else if Date.IsInPreviousWeek(Date.AddDays([Extract Date],-3)) then "Last Week" else "Other week")
in
    #"Added Custom"

77.png

Best Regards,
Community Support Team _ Eason

 

@v-easonf-msft : Thanks for help.

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.