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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
KEH1987
New Member

IF and Lookup Value off of two different sources

I have this formula from Excel =IF(VLOOKUP(AP6, maxduration, 2, FALSE)="na", (AI6-AH6), VLOOKUP(AP6, maxduration, 2, FALSE)

 

This AI and AH are policy expiration date and policy effective date.  I'm trying to find the date difference between the AH6 expiration date and AI6 effective date.  However, there are certain programs that have a max duration that is less than the date difference.  Those programs have a max limit of duration, so even if the difference in dates is 1600 days, they max out at 700.  The rest of the data that doesn't have a max duration is labled as "na".  If it's "na" then I just want the date difference between the expiration date and effective date. 

 

I have the two sources connected on "program", one source is Excel which has the max days on it as well as the programs with "na" on them, and the other source is SQL.  How can  I look up these certain programs and set their max duration based upon my excel source in powerbi and based upon the forumla above?

4 REPLIES 4
Anonymous
Not applicable

Hi @KEH1987 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1717053437407.png

(2) We can create a measure. 

Measure = 
var _day=DATEDIFF(MAX('Table'[policy expiration date]),MAX('Table'[policy effective date]),DAY)
var _max=INT(IF(MAX('Table'[max duration])="na",BLANK(),MAX('Table'[max duration])))
RETURN IF(MAX('Table'[max duration])="na",_day,IF(_day<=_max,_day,_max))

(3) Then the result is as follows.

vtangjiemsft_1-1717053480805.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Max Duration.pngScreenshot 5-30-24.pngScreenshot 2024-05-30 115203.png

It's still not capping R&W at 730.  I have a query that contains all the data and then I have an excel sheet that has the max duration on it.  I connected the two tables on "program" which is R&W, Tax, etc. but it's not capping my values as you can see in the screenshot.

amitchandak
Super User
Super User

@KEH1987 , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

But Earlier can help

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.