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 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Helpful resources

Announcements
Coming Soon: T-Shirt Design Contest

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

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.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors