Ntile usage in microstrategy - microstrategy

I need to compare last year sales and current year sales based on quintile score and should divide all the customers into 1,2,3,4,5 buckets using NTILE function.
Also need to include 2 more columns(old,new) in the report.
Old indicates customers who comes under 1,2,3,4,5 buckets in previous year but not purchased in current year.
New indicates customers who comes under 1,2,3,4,5 buckets in current year but not purchased in previous year.
For this i have created two custom groups one for previous year and other for current year.
In each custom group i have created 5 filters for 1,2,3,4,5 buckets and in one custom group i have included one more filter for old and in another custom group i have included filter for new.
In report results old and new columns are missing and remaining 1,2,3,4,5 values are getting for previous and current year in form of matrix(6*6).

Related

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."

Select if last 6 visits happened within 30 days

Using Crystal 2013, my report groups by customer_id. The details are the times(datetime) that the customer has visited. I've figured out how to detect a minimum of 6 visits, but I am want to check if those 6 visits happened within 30 days.
I want to show all of the visits for the customer, but I want to only show the groups that meet the criteria. Do I need to do a Whileprintingrecords to do a datediff between the first and 6th record for each group? How can I do this?
Here is what I have:
30 >= DateDiff ("DD", (if {Command.ROW} = 1 then {Command.Visit_START},
(if {Command.ROW} = 6 then{Command.Visit_STOP}))
Are you able to sort the group in Descending order? I have an idea but it will be less work for you if they're grouped newest to oldest.
WhileReadingRecords:
In each group you'll need to determine the 1st and 6th visit. (You're currently suppressing any groups with less than 6.) To do this, I would make a Shared Variable called Counter that increments by one every record and resets every time it reaches a new group. (Set it to zero in the Group Header.)
Next you'll need two more Shared Variables called FirstDate and SixthDate. These populate with the date value if Counter equals one or six respectively. Just like Counter you'll reset these every time the group changes.
WhilePrintingRecords:
If everything works, you should now have the two dates values you need for calculations. Add an additional clause in your current Suppression formula:
....
AND
DateDiff("d", FirstDate, SixthDate)

Crystal Reports Dynamically Grouping by Date

I'm relatively new to Crystal Reports and it seems like this should be easy, but I haven't been able to figure it out after a lot of googling. I'm working on a report in Crystal Reports XI that will show total hours logged by support staff for a date range and show sub totals by week, month, or both depending on the user input. My report is currently arranged as follows:
Group 1 Header - Support Staff Member
Group 2 Header - Ticket Closed Date with section printed monthly
Group 3 Header - Ticket Closed Date with section printed weekly
Group 4 Header - Ticket Category
Group 4 Footer - Sum of time logged in each category for the week
Group 3 Footer - Sum of time logged in all categories for the week
Group 2 Footer - Sum of time logged in all categories for the month
Group 1 Footer - Sum of all time logged
My original idea was just to suppress the header and footer for groups 2 and 3 when they weren't needed, but if I manually do that it still prints the records by week and month. Is there a way to not have the grouping at all unless the parameter says to show those totals? Or if that isn't an option, how would I use the parameter to change whether the group prints records weekly or monthly?
Thank you
Best option would be create a string parameter 'option' with values weekly and monthly.
Now create a formula grouping.
If ?parameter='weekly'
Then //your weekly code here
Else if ?parameter='monthly'
Then //your monthly code
Now use this formula in grouping instead of multiple groups.
Now when user selects option your grouping will change dynamically.
Hope this helps

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

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.