Forum Discussion

DairyG1's avatar
DairyG1
Helper I
3 years ago
Solved

Pass fail measure based on different date fields

Hi All,

 

Novice in power query,hope i can get some advise. 

I need to calculate pass/fail for different document types based off different date fields.

 

if doc type equals invoice and invoice date is less than creation date, Fail  [Obviously the pass  result side of that]

If doc type equals PL and departure date is less than creation date, Fail  [Again the pass result of that ]

 

Not sure how to approach this, hope i am clear in the ask

Many thanks

  • Hi DairyG1 

     

    Can you provide some sample data and expected result? If you have columns similar to below, you can add a custom column with code similar to below:

    if [Doc Type] = "Invoice" and [Invoice Date] < [Creation Date] then "Fail" else if [Doc Type] = "PL" and [Departure Date] < [Creation Date] then "Fail" else "Pass"

    Reference: Power Query If statement: nested ifs & multiple conditions (exceloffthegrid.com)

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

2 Replies

  • For an easy way to do it, you can break your code up into smaller portions using the conditional column option when you go to Add Column in the PQ menu and then based on the results of the columns created combine the logic or write an if statement in PQ using Custom Column option

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    Hi DairyG1 

     

    Can you provide some sample data and expected result? If you have columns similar to below, you can add a custom column with code similar to below:

    if [Doc Type] = "Invoice" and [Invoice Date] < [Creation Date] then "Fail" else if [Doc Type] = "PL" and [Departure Date] < [Creation Date] then "Fail" else "Pass"

    Reference: Power Query If statement: nested ifs & multiple conditions (exceloffthegrid.com)

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.