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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DannyMcMate
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
AnthonyTilley
Solution Sage
Solution Sage

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
AnthonyTilley
Solution Sage
Solution Sage

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!




Anonymous
Not applicable

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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