Display all the distinct values in 1 ssrs letter - sql-server

Hi I am creating an ssrs report (which is a letter format). And in the letter format, if a owner has highest sales for 3 products in same store I need those products to be listed in the same letter instead of 3 different letters. I have written an expression for the body of the letter. But that expression is taking all the products that has highest sales and generating 3 different letters. May I know how can I embed the product names within the body of the letter?
Sample That I need:
Hi Doc,
It has really great that you are making a huge impact on our product sales.
In our recent survey, we found that your store had the highest sales for following products:
Comforters
Cosmetics
Toys
Please continue this xyz.
NA Dept.

Related

Google Data Studio convert metric to dimension not working

I have imported my GA4 data into Google Data Studio and am trying to see how many giftcards have been sold by their value.
The item revenue metric in GA4 is equal to the giftcard value (i.e. revenue = $200 therefore $200 giftcard was sold).
I want to breakdown sales by giftcard value like so:
Giftcard (revenue)
Count
$200
4
$250
3
$300
6
To do this, I need to set a copy of item revenue as a dimension rather than a metric.
In Google Data Studio, I can create a calculated field with the following formula that should convert the item revenue into text:
CAST(Item Revenue AS TEXT)
The problem I'm having is that while the formula sets the field type as text, it is still regarded by GDS as a metric and can't be used as a dimension.
Even when I try to add text, GDS still recognises the field as a number:
CONCAT(CAST(Item Revenue AS TEXT), " giftcard")
To use a metric as a dimension you can make a combination of data. When defining the graphic element (table, for example) and the respective data source, just create a data combination, but do not combine the data with any other source and just define the combination with the initial data itself. So you will have the same data structure only through a combined structure.
When making a combination of data, data studio recognizes all calculated fields (metrics) as dimensions. Thus, it is possible to make the conversion.

I want to Create a Crystal Report of Paid Sales Invoices

When a Sales invoice is paid it is matched against the receipt.
A Sales invoice can also be matched against a credit note but there is no distinguishing flag.
I want the final report to only show the Paid invoices.
I am currently Grouping by Customer, then Matching Letter, then document, so at this level you can see if the match is with a receipt or with credit notes.
I output the Group footer of the document giving me a list of documents, which for a customer payment will start with the Receipt, followed by one or more invoices totaling the value of the receipt:
GF4 Customer A Match BC REC101009798 GBP240.00
GF4 Customer A Match BC INV101059389 ‘new field’ GBP120.00
GF4 Customer A Match BC INV101059390 ‘new field’ GBP120.00
If the matching is as a result of a customer payment, the Receipt will always be on the first line in the group output.
How do I create a ’new field’ on the Invoice lines that will say “Paid” , it doesn’t matter if the new field also appears on the Receipt line?
I have tried to use a formula on the group footer referencing the document type but of course when the document type changes, so does the result of the formula.
Having a success on the first line I have been concentrating on trying to copy the result on to the successive lines so thought a fresh pair of eyes might help.
Many thanks
Use Subreport. You can pass inv no or doc type to subreport and get status . Put subreport in invoice line.
Thank you Pals, I have solved this with a colleague.
We revised the formula on the Group Footer. First we created a formula that assigned a 1 to a Receipt and 0 to all other docments: IF {GACCDUDATE.TYP_0} = "REC01" THEN 1 ELSE 0. Next we created a SUM formula: IF Sum({#rowIsPaid}, {GACCENTRYD.MTC_0}) > 0 THEN "Paid"
and put this on the Group footer.

SQL syntax to calculate total menu items per meal orderID across multiple meal orderIDs

I am new to SQL and Stack overflow and have a question about SQL Server syntax. i have searched online but I am not finding what I need and I would appreciate your assistance in this matter.
I have data in a source table for meal orders (each with a specific ID (e.g. 12345C) and items of each order (e.g. sandwich, drink, chips), each with an associated number starting with 1. For instance, the sandwich would have an item number of 1, the chips would be item # 2, and the drink would be item # 3 for the same orderID 12345C. The prior example would therefore have 3 rows of data in the source table for orderID 12345C.
My questions are these:
how do I use a SQL expression to determine the number of items per each order (e.g. 3 for the above example, which is also the maximum value for item number for each orderID)
and then add all of these items per order across hundreds of orders per day to determine the daily total number of items ordered.
So, if I had 3 orders in one day - one with 2 items, the second with 3 items, and the third with 4 items, I would like my final number to be 9.
This number is for use in a Sisense dashboard that allows SQL syntax in the field definition. Thank you for your help!
It is a bit difficult to explain but I am not able to use a query from a table because I am working with a dashboard in Sisense so I am adding fields in a pivot display and one of the fields I would like to include is the total count of order items per day (across several dozen orderIDs).
Here is an example of the data in the table: from the example I would like the final answer for orderID 1787588 to be 3 (there are 3 items within the order).

Is it possible to create an SQL query that displays results like this?

Background
I have a database that hold records of all assets in an office. Each asset have a condition, a category name and an age.
A ConditionID can be;
In use
Spare
In Circulation
CategoryID are;
Phone
PC
Laptop
and Age is just a field called AquiredDate which holds records like;
2009-04-24 15:07:51.257
Example
I've created an example of the inputs of the query to explain better what I need if possible.
NB.
Inputs are in Orange in the above example.
I've split the example into two separate queries.
Count would be the output
Question
Is this type of query and result set possible using SQL alone? And if so where do I start? Would it be easier to use Ms Excel also?
Yes it is possible, for your orange fields you can just e.g.
where CategoryID ='Phone' and ConditionID in ('In use', 'In Circulation')
For the yellow one you could do a datediff of days of accuired date to now and divide it by 365 and floor that value, to get the last one (6+ years category) you need to take the minimum of 5 and the calculated value so you get 0 for all between 0-1 year old etc. until 5 which has everything above 6 years.
When you group by that calculated column and select the additional the count you get what you desire.

Graph line from multiple fields in Microsoft Report Builder

I am using Microsoft SQL Server Report Builder and am trying to graph a line based on multiple fields within a Dataset. Basically I have a Dataset containing a lot of elements, each of which has a category field, and twenty fields associated with previous year values. I want to be able to group by category, then graph a line for each category that looks up the summed value for each of the twenty years.
So I want the X values for the line to be years, and the Y values to be whatever the summed total is for that category, in that year.
I'm going to assume you have multiple rows for each category with a field for the year, category, and value. If it is a single row which contains all of the values for each year then things will be a bit tougher.
On your line chart you should make the category group the year, make the series group the category, and then make the value the SUM() of the value field.

Resources