How To EXPRESSION with WHERE " count Orders WHERE customer = Mr. Smith "? - jasper-reports

I am a beginner in iReport and I cant program Java so I hope you can give me an idea.
I've already managed to make a chart that displays how often all customers have ordered in february, march,... etc.
Thats how I did it:
In category expression I have: $F{Month}
In value expression I have : $F{count(Orders)}
But I want to display how often only one customer (for example customer a) has ordered in february, march,... etc.
I have the following values which i can use:
Month, Orders and Customers(here are all customer names saved)
-------//-----------UPDATE--------------//-----------------------------------
I want to display a chart which represents the total orders per month of a customer. But iam trying to display my 3 customers (my database has only 3) in only one chart (stacked).
For example(see picture above): I want to display the total orders from Customer A (yellow) in february. And I want to display the total orders from Customer B (blue) in february and the same for customer C.
The customers should be displayed stacked (3 in every month) and every customer should have a different color plus the total orders from every customer should be displayed ...like in picture above for example:
customer A(yellow) made 3 total orders in february, Customer B(blue) made 2 total orders in february, customer C..etc.
it is very important that every month displays 3 customers...stacked.
How do I do this?
I appreciate every idea.

From what I have understood from your question, you want to show a chart which represents the total orders per month of a customer.
You need not use stacked bar graph for this purpose.
You may want to use bar graph which would serve your purpose.
If you want to see the chart per customer, create one parameter $P{customer} and pass it into your query.
Refer document iReport-Ultimate-Guide-3 on how to create parameters and to use it in queries.
e.g:
select customer,month,count(orders)
from <your table>
where customer=$P{customer}
group by month
The above approach would work if you want to see the details for only one customer.
**Here is my solution after your update.**
From your update, it seems like you want to represent the total orders per month for all the customers.And you want to use stacked chart for the same.
Then what you have done is correct but have missed to add a field to your 'Series Expression'
Add your field customer to your series expression and this will resolve your problem i.e,
Series Expression : $F{customer}
Category expression : $F{Month}
Value expression : $F{count(Orders)}
This will display the chart in the format you have specified.

Create a paramter that takes your customer name $P{customerName}
and another takes month $P{month}
pass these two paramters to your sql like that
SELECT customer_name, order_count FROM customers
bla.. bla..
WHERE customer_name=$P{customerName} and month=$P{month}
then create a chart with only one serie to show one customer as one color. Not like yours with 3 colors.
Fell free to ask for more specific detail.

Related

Filemaker: display related records based on date

I have 3 tables,
Table 1:
Client
Table 2:
Followups
Table 3:
Referrals
It's a one to many relationship where one client can have multiple followup or referrals.
How do I display the Followups and Referrals between 2 dates?
I have a summary field which counts the total of each followup and referrals but they show me all the count rather than in between a given date
In your relationship graph make a new table occurance that restricts the related set based on a date range. Here is an example image. You can make "date one" and "date two" globals so that they are not stored, and operate across all records. Base your sum / count calcuations based on this relationship.
Otherwise you can use a sub-summary on your layout in list view, and place the Summary fields in the sub summary. The summary field will show the sum for that sub section.
Another option is to place the summary field inside a one-row portal and filter the portal to show only records within the desired range.
This requires much less resources than adding filtered relationships - but it can be slow if you have too many related records.

Tableau dashboard filter action excluding date but including clients represented in date clicked

I have a bar chart below that shows the sum of clients by month. I want to be able to click on a month and use a dashboard action to navigate to all data for each of the clients represented in the month that was clicked. Basically, I want to exclude the date portion of the filtering.
I currently do this by navigating to a sheet that includes client_id and filters for the single month and then I select all client_ids and action to another sheet that filters by the selected client_ids and not date. I want to remove the middle step.
If the above selected month is April 2020 and represented 64 clients, my current action takes me to a sheet that has each client on a row and shows me their sum of invoices for April 2020. I want to see those same 64 clients for all months they have transactions in.
This one may be tough to accomplish, but I definitely see what you're setting out to do. If you're using a date dimension on your action it will use that data to filter.
However, there may be some other options depending on what you're needing. If don't need to see the invoice ids and only want to see the sum of invoices for all months you could use a LOD (Level of Detail) calculated field.
You would create a calculated field like:
{ FIXED [client_id] : SUM([your invoice amount measure])}
Use this as a new column to get the sum of all invoices in your data set for each client.

How can I deselect an entire group based on the value of one member of the group?

We have customers that order product on an annual basis. I have a report that needs to show only customers and related orders that have NOT placed an order in the current year. I filter all orders down to the current year and the year prior.
Right now, if a customer has orders for last year, I want them to show on the report, but once the customer places an order for the current year, I want both the current year order and the prior year orders to drop off the report.
Our salespeople use this report to manage the customers that need to be contacted in the current year. Once the report is empty, they are done for the year.
I know how to suppress the rows based on the value of a single member of the group, but suppressing them does not remove them from the summary calculations, so I need them to either disappear, or I need to be able to change all values to zero for that customer once they place a new order.
Thank You.
I created a running total field to trap the current year.
If Year(#Date)=2019 then 0 else Qty
When I put the formula into a qty formula, I get the "Summary has been specified for a non-recurring field"

Segregate Products based on shipping <SQL>

I have 10 different products (A,B,C),..,J)have multiple purchase dates (by various customers) and delivery dates. I want to see which products have the date difference of less than 5 days. If the date difference is less than 5 days, which products have customer rating less more than 3.If the above criteria is satisfied I want to fetch those products that has the minimum date difference from the queue along with the "Important_date".If there are same minimum date difference for a particular product then I would like to select the top one among the same product in recent times and mark the purchase date as the "Important_date".
The columns in the table are: Product,Purchasedate,deliverydate,date_difference,customer_rating.
I am trying to use case statements to solve the problem in PostgreSQL.
I am looking for an output which will give me all the columns of the table along with "Important_date."

Access Crosstab or Form based on 2 tables with dates

There are a few answers here already that have part answered my challenge in Access but not fully.
I have 2 tables that form the basis of my database: customers and items
I have a further 2 tables; one for order quantities against customers and items (orders_a), and one for forecast quantities against customers and items (forecast_a).
forecast_a and orders_a also have a date for each customer and item combination (basically there will be 12 dates only for the 12 months of the year - 01/01/12,01/02/12,01/03/12 etc.)
Because a user will want to manually forecast quantities for a full year for each customer and each item, if there were 2 customers and 2 items, the forecast_a table would contain 48 rows. 2 items x 2 customers = 4, 4 x 12 dates = 48. The same goes for the orders_a.
I know this is a slightly unusual set up but the user requires visibility of a full year.
My main challenge based on this is as follows:
A user will want to see a form with customers in the first column, items in the second and then (like a crosstab): Jan Forecast Qty, Jan Order Qty, Feb Forecast Qty, Feb Order Qty etc.
Therefore how would I create a crosstab to pull both these tables together, and how would I go about creating a form for data entry off the back of it?
I may well be constructing my database the wrong way but the fact that the user needs a 'grid' where every entry is manual means I can't just have a form that creates a record one at a time for orders or forecasts.
Thanks in advance!
Nick
The problem you have is that this is a task that is in essence a spreadsheet task. Accordingly it may be best handled in Excel. To achieve this create an Excel object, create a blank worksheet, populate it with the data, then have a button to suck it back into the database when the user has finished.