Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8435043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:49:19+00:00 2026-06-10T06:49:19+00:00

Hey guys i could really use some help coding this IF statement! I managed

  • 0

Hey guys i could really use some help coding this IF statement! I managed to fit in 2 of the conditions, not sure how the 3rd (calculation) would fit in. This is the calc in pseudocode;

IF Producer_Type = 'Oil', Unallocated OIL&GAS = UnallocatedLossesOIL
IF Producer_Type = 'Gas', Unallocated OIL&GAS = UnallocatedLossesGAS
ELSE Unallocated OIL GAS = UnallocatedLossesOIL(MPPOil ÷ (MPPOil + MPPGas)) + 
UnallocatedLossesGAS(MPPGas ÷ (MPPOil + MPPGas))

This is my code:

SELECT qb1.CompanyName, qb1.AssetName, qb1.Year, 
IIf(qb1.Producer_Type='Oil',qb1.DatapointValue, qb2.DatapointValue) AS UnallocatedOilGas
FROM PEBaseQuery AS qb1 INNER JOIN PEBaseQuery AS qb2 ON qb1.Assetname=qb2.AssetName
WHERE qb1.DatapointID=2026 And qb2.DatapointID=2027;

Where DatapointID of 2026 is UnallocatedLossesOIL and 2027 is UnallocatedLossesGAS. The calculation needs to reference MPPOil and MPPGas values (relating to particular companies/assets/yearswhich are results from two separate queries… Any help would be much appreciated! Sorry if some of this doesnt make sense..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:49:20+00:00Added an answer on June 10, 2026 at 6:49 am

    How about nesting the if condition? I mean, if thats possible, this should work:

    SELECT qb1.CompanyName, qb1.AssetName, qb1.Year, 
    IIf(qb1.Producer_Type='Oil', qb1.DatapointValue, 
      IIF(qb1.Producer_Type='Gas', qb2.DatapointValue,
       qb1.DatapointValue * (MPPOil / (MPPOil + MPPGas)) + 
       qb2.DatapointValue * (MPPGas / (MPPOil + MPPGas)) )) AS UnallocatedOilGas
    FROM PEBaseQuery AS qb1 INNER JOIN PEBaseQuery AS qb2 ON qb1.Assetname=qb2.AssetName
    WHERE qb1.DatapointID=2026 And qb2.DatapointID=2027;
    

    Regarding the values of MPPGas and MPPOil, I’m not sure where to find them, so left them as they are.
    I hope this works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys was hoping you could help me out, Not sure if I always
Hey guys I'm not sure how to phrase this to get the correct search,
Hey guys, This could be a noob question, but I really can't find any
Hey guys, I could only find 1 thread on this, and it didn't really
Hey guys, what function could I use to say, if this radio button is
Hey guys was hoping you could help me out. basically i'm working on a
hey guys was hoping you could help me out, I am relatively new to
Hey guys i have looked as much as i could and i could not
Hey guys I was wondering if someone could provide a little help. I've been
hey guys having this really simple problem but cant seem to figure out have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.