Ag-Grid - display custom groups without having records in that group? - ag-grid

I've got a grid with records grouped by Category. Here's an example of the data I'd have:
[{id:1, category:"a", status: "open"},{id:2, category:"b", status: "open"},{id:3, category:"b", status: "closed"}]
So, grouped by category, it would show
a (1)
b (2)
and if I click the expander for "b", it would show records 2 and 3.
Now.... let's say I change the category of record 1 to "b", it would show:
b (3)
What my client wants to see is this:
a (0)
b (3)
Since the grouping is automatic, can I do that?
I tried adding a fake record and then customizing the group header title to show 0, since it would otherwise show 1 record (the blank one), but it's such a lame hack, I was sure there must be a better way.

Related

Count of group dimensions item in Tableau

I'm fairly new to tableau and I'm having the following issue. Below is a sample of the data I'm using.
Customer No | Item
___________________
1 A
1 B
2 A
3 A
4 A
4 B
5 B
6 A
I'm trying to get a count of how many customers bought Item A and B. So far I tried doing a separate group by combining A and B but I get the total result of 8. I also tried doing a calculation and I'm getting the same result of 8. Can someone please point me to the right direction on how to get this result. Thanks!
This is the result I'm trying to get:
Item| Count
A 5
B 3
A and B 2
I recreated your exact dataset and pasted it into Tableau so you could see a couple of examples.
Here's how you can see the number of customers who purchased an individual item, plus the number of customers who purchased both items.
Your calculation will be:
IF { FIXED [Customer No]: COUNTD([Item]) } = 1 THEN
[Item]
ELSE
'Both A and B'
END
And you'll need to set your view up to look like this:
Below are ways you can see when both items were purchased.
Boolean OR
The calculation you'll want to use is:
ATTR([ITEM]) = 'A' OR ATTR([ITEM]) = 'B'
And you'll want to set up your view to look like this:
A, B or Both
If you would like a bit more specificity in your result, you might try:
IF ATTR([Item]) = 'A' THEN
'A'
ELSEIF ATTR([Item]) = 'B' THEN
'B'
ELSE
'BOTH'
END
Replacing the previous calculation with the new looks like this:
More than 1 item
If the specific items purchased don't matter, you could use this logic.
COUNTD([Item]) > 1
Replacing the previous calculation with this one would look like:
More than 1 Item using a window function (probably overkill)
The calculation you'll need to use is:
WINDOW_COUNT(COUNTD([Item]))
Because this is a Window function, we'll need to specify how it's calculated across our dimensions. To do this click the down arrow on the right-hand side of the pill and select Edit Table Calculation...
You'll then need to set these settings:
I'll add the calculation we created in the first example ([A and B]) to the filter shelf and select True. That should give you something that looks like:
More than 1 item using a Level of Detail expression
The calculation for this example is:
{ EXCLUDE [Item]: COUNTD([Item]) }
You'll view should look like:
As you can see Tableau is quite flexible. Hope these examples were helpful!
You might want to use Tableau’s set feature to approach problems like this.
For example, right click on the field [Customer No] in the data pane (i.e. left sidebar) and choose the “Create Set” command. Click “Use All” at the top of the set panel and then click the Condition tab. Define the set using the condition MAX([Item] = “A”). Name the set “Customers who bought A”.
Similarly, create a set of customers who bought item B. You can then select both sets in the data pane, and create a combined set to be the intersection, that is, customers who bought both an item A and an item B.
You can think of a set as either a mathematical set of the members of a field that belong to the set (i.e. a set of customer ids) or as Boolean function defined for each data record in the data source indicating whether that data record is associated with the set (i.e. a Boolean function that operates on transactions to say whether the associated customer ID is in the set. A key to keep in mind for the condition formulas used here is that the condition is an aggregate formula, operating on a block of data records for a customer ID to determine whether the customer ID is in the set.
Once you have defined your sets of interest, you can use them in many ways - in calculated fields, as filters, as dimensions on shelves in a visualization, in set actions, to combine with other sets ...
To define a measure that counts the customers in a set, create a calculated field such as “[Num A Customers]” as COUNTD(if [Customers who bought A] then [Customer ID] end) Do the same for whatever other sets you are interested in. Then you can use those measures (probably with Measure Names and Measure Values) to make your viz.

Show 0 for values with missing data

I have a dimension I am showing in a text table that can have one of 3 possibilities "A", "B", or "C" and I want at all times to have A, B and C shown in a text table even if one of them has 0 occurrences. The issue is that I am filtering this based on date, so it is possible that for example B may not exist, but I still want to have a 0 printed for B.
I have gone to Analysis -> Table layout -> show empty rows which will show "B", but in the count display it shows a blank. How can I get it to display a 0?
This problem is very famous among tableau users and I still did not see a generic tableau-only solution. All proper solutions start with injecting rows to your data which I assume you do not want this.
Below method will only work if you have a Date Dimension on the measure and no-data dates are not completely filtered-out; so you will be seeing zeros even though that date has no data as you may see on below screenshot.
When you filter out the no-data dates, unfortunately you will keep on seeing NULLs.
If you are using the SUM of Number of Records as your occurrences, then you may create a calculated field as below and use it in your pane:
ZN(LOOKUP(SUM([Number of Records]),0))
You can leave the Default Table Calculation as Automatic so the Results are computed along Table (accross).

Print Multiple Copies of Record Crystal Reports

I have a report that is only one record, however, the user specifies how many times it needs printed, let's say 10. Each time it prints it prints 4 of the same report. Like this, Page 1 x 4, Page 2 x 4, Page 3 x 4, etc. With 10 copes their will be 40 pages altogether.
Update:
I was able to get all the pages I needed based on the values the user inputs. So if there are 10 pallets I have 40 pages of labels, which is correct. Now the control number part that needs to be displayed. It is kind of like a page number but every 4 pages the number needs to increment by 1. I assume I can use WhilePrinterRecords and some how increment, but I am still new to Crystal and unfamiliar with it.
Example:
Page 1: Control number 1
Page 2: Control number 1
Page 3: Control number 1
Page 4: Control number 1
Page 5: Control number 2
Page 6: Control number 2
Page 7: Control number 2
Page 8: Control number 2
This would continue until there is no more pages to print.
if you want 4 copies for each label, what you could do is create 4 sections on the report with the same info. Make sure that you assign the label size to each page(e.g. 4x6). e.g. if you have that info on your header, create PHa, PHb, PHc and PHd, same for details or PF.
don't know if this could work for you, but at least is a recommendation. You can create suppressed sections with the same info(e.g. 10 sections) and create a parameter that control that suppress condition defaulted in 4. If the user what to print 5, it will enable section 5th, same if want to print 3 it will suppress the 4th.
Upadte: how to get the increment:
place a formula on your page footer like below one. It will return value when gets an integer and suppress it when is equal to 0(right click on it, number tab, customize, suppress if 0).
if pagenumber = Ceiling(pageNumber,4) then numbervar page := page +1
then place another formula on your PF as well like below one and suppress it when pagenumber = Ceiling(pageNumber,4) so it won't show when the other has value and put one overlapping the other to get the value in the same place.
if {1st formula} <> 0 then numbervar page1 := {1st formula};
page1 + 1
2nd Update:
Because is a label and your details are acting as a new page do this:
create a new detail section, so you will have details a and b and place your formulas on details b
I have used additional tables for such tricks; these tables must be linked to report to multiply main query results. Some care has to be taken to not allow multiple users printouts to mix.
Example, assuming your report query has some unique id to link and your user/session has also some unique id:
you create table cr_special(reportid int, userid int, ctlnumber int)
you design report, linked to this table by reportid and filtered by userid; changing ctlnumber field is taken from your special table
before printing, you delete all records with reportid/userid combo and insert new ones
you print report, giving userid as parameter
Say you want to print 10 reports with increasing numbers - then you insert 10 records into your special table with ctlnumber increasing from 1 to 10.
Variation of this solution is to use some other non-related table, like our all-dates-containing dates table :)
Both of these solutions are ugly, but they usually work.
Another approach is to use some stored procedure to return these sequential numbers as records and link your report to such procedure; Crystal Reports and stored procedures do not behave always well however.

Microsoft Access - I want my mainform to create X records in subform base on fields automatically

I been putting a lot of thought into the logic behind this, and I can't seem to figure out the best way to handle this problem.
1 - Afterinsert
2 - unbound fields + button to insert X times
3 - I am open for suggestions
The form
The relationship
I was debating on using AfterInsert to handle everything. Since NoOfBoxes will decide the amount of records and I would only need to duplicate the value of MergeNo and isCommission to the subform. But the problem is, I need to also auto fill the item, which made me think of solutions number 2.
The reasoning behind going with number 2 is; my receive report header doesn't contains the item information and since a subform can only have 1 type of item but multiple of them. I was hitting toward number 2.
Solution number 2 would be multiple unbound fields which pulled the information into a combo box, or enter the information needed and hit a button which will then transfer all that data to the subform and create the correct amount of records.
unbound fields = itemcode, mergeNo, isCommission, and NoOfBoxes.
I think you need a Numbers table with integers from 1 or 0 to an appropriate number, you can then say something like:
INSERT INTO ATable ( MergeNo, IsCommission )
SELECT [Forms]![aForm]![MergeNo] AS MergeNo,
[Forms]![aForm]![IsCommission ] AS IsCommission
FROM Numbers
WHERE Numbers.Number<=[Forms]![aForm]![NoOfBoxes]
Do not forget that if the numbers table starts from 0, it is less than, not less than or equal to.

SSRS - group by on top of page

in Reporting Services when we group by one column we get the group in the left of the detail. Is it possible to make that group by in the top, just like in Crystal Reports?
Page 1:
Invoice A - name A (on top of page)
Detail 1
Detail 2
Page 2:
Invoice B - name B (on top of page)
Detail 1
Detail 2
I can only get
Invoice A - name A - Detail 1
Invoice A - name A - Detail 2
Invoice B - name B - Detail 1
Invoice B - name B - Detail 2
I've gotten this to work, but it's a pain.
First, make sure that your table is set to page break after every group.
Click on the box in the table that has the info you want to move to the top of the field (the name, the invoice, whatever) and get its name.
Wherever you want that data (i.e. in the page header), add a textbox whose value is =First(ReportItems![name].Value).
Unfortunately, that will leave you with the group heading still also present in the table. That's not necessarily a bad thing.
If you want to completely do away with that:
Stick your whole page in a List control, also set to page break after this element.
Set the List to group by invoice/name/whatever
Do the same as in the first option for the header
Put the table inside the list, with all grouping turned off. I can't remember right now whether you have to manually tell it to use the List's dataset; try the default first and see if it works.