cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DannyMcMate Frequent Visitor
Frequent Visitor

Returning the following wednesday from a date value if certain criteria are met

Hi there,

 

New to Power BI.

 

I have a data set relating to payments and am trying to solve the following problem. The payment date in the dataset relates to the date the payment was submitted by the accounting system, and not the date it cleared from the bank (usually five days later). I therefore need to create a calcualted column that when certain criteria are met, ie when payment method=a certain value and payment priority=a certain value, it takes the payment date and returns the date of the following wednesday.

 

Any pointers or help would be much appreciated.

 

Kind Regards,

 

D

1 ACCEPTED SOLUTION

Accepted Solutions
Super User I
Super User I

Re: Returning the following wednesday from a date value if certain criteria are met

this depends on what you mean by the following Wednesday.

 

below are tow examples the first will always return the next avilable wednesday so for example if the date was tuesday the 7th of may 2019 then the next wednesday would be wedneday the 3rd of MAY

 

Column =
Var m = Table1[Method] = "BANK"
var p = Table1[Priority] = 1
var d = Table1[Payment Date]
Var wd = WEEKDAY(d,2)
var nextwed = d + (3-wd) + IF(wd>3,7,0)

var ret = if(and(m,p),nextwed,blank())

return nextwed

 

the second example will always give the wednesday of the following week so in the example above instead of giving the 8th it will give the 15th 

 

Column =
Var m = Table1[Method] = "BANK"
var p = Table1[Priority] = 1
var d = Table1[Payment Date]
var nextwed = d + (3-WEEKDAY(d,2)) + 7

var ret = if(and(m,p),nextwed,blank())

return ret
 
 
for both just change the method and priority checks to your criteria 

View solution in original post

2 REPLIES 2
Highlighted
Nick_kz Regular Visitor
Regular Visitor

Re: Returning the following wednesday from a date value if certain criteria are met

Hi @DannyMcMate  

 

Try to use the language function in M in the query editor.

Create a calculated column ( if [type_cost] = "X" and [Sum] >10500 then [date]+5 else [date] )   

Super User I
Super User I

Re: Returning the following wednesday from a date value if certain criteria are met

this depends on what you mean by the following Wednesday.

 

below are tow examples the first will always return the next avilable wednesday so for example if the date was tuesday the 7th of may 2019 then the next wednesday would be wedneday the 3rd of MAY

 

Column =
Var m = Table1[Method] = "BANK"
var p = Table1[Priority] = 1
var d = Table1[Payment Date]
Var wd = WEEKDAY(d,2)
var nextwed = d + (3-wd) + IF(wd>3,7,0)

var ret = if(and(m,p),nextwed,blank())

return nextwed

 

the second example will always give the wednesday of the following week so in the example above instead of giving the 8th it will give the 15th 

 

Column =
Var m = Table1[Method] = "BANK"
var p = Table1[Priority] = 1
var d = Table1[Payment Date]
var nextwed = d + (3-WEEKDAY(d,2)) + 7

var ret = if(and(m,p),nextwed,blank())

return ret
 
 
for both just change the method and priority checks to your criteria 

View solution in original post

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors