cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
AnthonyTilley Established Member
Established Member

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
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] )   

AnthonyTilley Established Member
Established Member

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
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

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

Top Solution Authors
Top Kudoed Authors (Last 30 Days)