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 8244719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:56:54+00:00 2026-06-07T21:56:54+00:00

I need a variable expression that calls a sub dataset with a parameter attached.

  • 0

I need a variable expression that calls a sub dataset with a parameter attached.

I have a dataset which is returning a list of grocery purchases made. Something like:

Milk, NJ, $1.23

Chicken, DE, $5.45

Milk, NY, $1.44

I am able to get a sum of the prices using a summation variable on the purchase price. However, I need a total that takes the state tax into account. In the above example, let’s say the NJ sales tax multiplier is 1.06 and NY sales tax is 1.08. Instead of my milk sum being 2.76 (=1.44 + 1.23), I need it to be 2.859 (=1.23*1.06 + 1.44*1.08).

I have a subdataset SALES_TAX that with the query:

SELECT tax_multiplier FROM mydb.sales_tax WHERE state=$P{STATE}

and I essentially need:

Sum($F{PURCHASE_PRICE} * $V{getTax($F{PURCHASE_STATE)})

How can I accomplish this? What will my getTax variable need to look like to query the SALES_TAX sub dataset with the purchase state field from the main dataset?

  • 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-07T21:56:56+00:00Added an answer on June 7, 2026 at 9:56 pm

    Marianna,

    Could you build a tax field into your query? You could create a case statement to evaluate the state where the purchase was made. Your query could spit out the pre-tax price, the tax value, and the post-tax price. The case statement would look something like (I’m using Oracle, you may need to adjust for your database):

     CASE
     WHEN PURCHASE_STATE = 'NY' THEN 1.08          
     WHEN PURCHASE_STATE = 'NJ' THEN 1.06     
     WHEN PURCHASE_STATE = 'DE' THEN 1.00    
     ELSE 1.05                               /** default value **/
     END AS TAX_RATE
    

    If you wanted to do this in iReport, I would suggest creating a variable to apply the tax rate. The variable expression would be something like:

     $F{PURCHASE_STATE} == "NY" ? "1.08" : 
       $F{PURCHASE_STATE} == "NJ" ? "1.06" :
         $F{PURCHASE_STATE} == "DE" ? "1.00" : "1.05"
    

    Then, your iReport detail band should output one text field with the text field expression
    $F{PURCHASE_PRICE}, one text field with the text field expression $V{TAX_RATE}, and one text field with the text field expression $F{PURCHASE_PRICE}*$V{TAX_RATE}.

    If you want to use a subquery in your SQL query to find the sales tax, you could:

     SELECT P.PURCHASE_ITEM                   AS ITEM, 
          P.PURCHASE_PRICE                    AS PRICE, 
          P.PURCHASE_STATE                    AS STATE, 
          (SELECT T.TAX_RATE 
               FROM TAX_TABLE T 
               WHERE T.STATE = P.PURCHASE_STATE
          )                                   AS TAX_RATE, 
          PURCHASE_OTHER_INFO                 AS OTHER
     FROM PURCHASE_TABLE P
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help, I have a regular expression that appears to work just fine
i have a string like that: [variable = value][variable2=value2][Some text inside] I need to
I have an application in which I need to combine strings within a variable
I need a variable that is available from any function in my code, but
In a javascript file (e.g. script.js) I need a variable that contains the absolute
I need a static variable that points to itself to use when referencing the
I need to pass a variable which is captured from client side via jquery
I need to assign a variable which will be used to create the id
I have this regex variable: var regexp = new RegExp(RegExp.quote(myExpression) + '\\b', 'g'); which
I have a method that currently takes a Func<Product, string> as a parameter, but

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.