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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DairyG1
Helper I
Helper I

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

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
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"

vjingzhang_0-1681810700025.png

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.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
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"

vjingzhang_0-1681810700025.png

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.

datawailor
Advocate II
Advocate II

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors