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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.