Given a report with a data item Customer and a data item SalesLine.
I display all Saleslines from each Customer. How do I filter these Customers out which does not have Sales Line? Where do I need to put the filter?
In the OnAfterGetRecord trigger for each Customer, do a count of their SalesLines and if the count is zero then use CurrReport.Skip() to skip that data item (Customer).
Something like this:
IF SalesLines.COUNT = 0 THEN BEGIN
CurrReport.SKIP()
END
Related
i'm trying to append the word "End" in the next row at the end of a Query, i saw here a code to do it but today this doens't work, add the word at the end of the first column header and do not load the query.
=QUERY('PT--------------'!A1:M953,"select * where (I<>'N/A')",1)&"End"
Results in:
Cash AccountEnd
without the '&"end"' it does the Query:
Cash Account Date Reference Receipt Payment method Client ID Amount Number of Distributions Invoice Paid G/L Account Sales Tax ID TOTAL PAID IN INVOICES Prepayment
what i'm doing wrong?
try:
=INDEX({QUERY('PT--------------'!A1:M953,
"where I<>'N/A'", 1); {"End", IFERROR(SEQUENCE(1, 12)/0)}})
I've tables Items table as (Stock) and Sales Transaction so when I want to sale items from Items table Sales Transaction will generate id(auto increment) and will have all items added by user to sale.
But here is problem, how single transaction id can have multiple items in a row or how
Sales Transaction can generate same id for each row?
So even if I'll insert items to Sales Transaction for each item will have different id and so I'll not able to search reports correctly.
That will affect functionality.
I'm thinking to add all items in a single row like this:
So is there any other way to solve my problem?
To add a column, you need to alter the current table:
ALTER TABLE "Sales Transaction"
ADD COLUMN TransactionNumber INT NOT NULL
When you are inserting into this table you will need something like this:
DECLARE #TransNumber INT = (SELECT CASE WHEN MAX(TransactionNumber) IS NULL THEN 1 ELSE MAX(TransactionNumber) + 1 END FROM "Sales Transaction")
INSERT INTO "Sales Transaction" ("Item Name", Qty., Price, "Cust. Name", Tax, Discount, Total, TransactionNumber)
VALUES
('Pen',1,10,'John Smith',0,0,10,#TransNumber),
('Pencil',2,7,'John Smith',0,0,14.00,#TransNumber)
Since the TransactionNumber will be the same for both rows, you can search by that.
The problem is with data fields need to be checked to determine if the "Transaction_Amount" is an expense or Income. This information is stored in the "categories" and the table associates a budget category as an "expense/Income".
Based on the "Income/expense" notation the actual transaction amount is populated as an expense (-) or Income (+) and updated in the "Account_Trasactions" table as either an expense or Income Item. In each case, the value is added to the existing value in the Account_Transactions" Table in the record associated with that budget.
So the goal is to track all budget categories as "budgeted" - "actual" = "Balance".
Here is my code and it fails to update the field Actual_amount on the form!
Private Sub Actual_amount_GotFocus()
'check for expense or income and adjust actual ammount of transaction'
[iif [category].[income/expense]="expense", (actual_Amount)=((Transaction_amount)*-1),actual_amount = Transaction_amount)]
'Update category table'
[Category].[Actual_Amount] [Actual_Amount]
End Sub
What am I doing wrong??
The DB has a table namely records. Among the fields are product_id,quantity,store_id.
I need to get the sum total of quantity of those rows which belong to a certain store_id and then have same product_id values.
For example , the table has values : (2,3,4),(2,1,5),(1 2,2,4) Then I need to get the sum total of quantity along with other columns from 1st and 3rd rows. And the 2nd row will also be present in the result.
Let us assume the Controller name to be RecordController and the model name to be Record.
How should I write the query ?
Edit : the table has values : (2,3,4),(2,1,5),(1 2,2,4)
It can be done using a single query.
Try This:-
DB::table('records')
->select('product_id',DB::raw('sum(quantity) as quantity'),'store_id')
->groupBy('product_id')
->groupBy('store_id')
->get();
Explanation:
This query will fetch all the records & group them by product_id & store_id so will only get a single row for a single product in the store. And then it will display the sum of quantity in the output.
Update:-
Using ORM:-
\App\YourModelName::select('product_id',DB::raw('sum(quantity) as quantity'),'store_id')
->groupBy('product_id')
->groupBy('store_id')
->get();
But you need to write the raw query in any case, it can't be done using default ORM functionality
I have the data table below:
--> Click here for the picture.
I want to add new column and count how times an employee is present in the office something like this:
--> Click here for the picture.
How can I count it in expression given that I have group in Employee.
Thank you.
You can use LookupSet() function to get the In-Office count. Add a tablix with the Employee Name group.
Note the Days Worked column is inside the Employee group scope but outside the details group scope.
Use this expression to get the count of Attendance In-Office per employee:
=LookupSet(Fields!Employee.Value & "-" & "In-Office",
Fields!Employee.Value & "-" & Fields!Attendance.Value,
Fields!Attendance.Value,"DataSetName"
).Length
Replace DataSetName by the actual name of your dataset. It will produce the below tablix:
UPDATE: Based on OP's comment.
Replace the LookupSet expression and use this instead to add multiple criteria to the filtered count.
=COUNT(IIF(Fields!Attendance.Value="In-Office" OR
Fields!Attendance.Value="Out for Official Business",
Fields!Attendance.Value,Nothing))
It counts In-Office and Out for Official Business rows in the given group.
Let me know if this helps.
You can do it via SQL script.
SELECT A.EMPLOYEE_NAME,A.DATE,A.ATTENDANCE,B.DAYS_WORKED
FROM TABLE A
LEFT JOIN
(SELECT EMPLOYEE_NAME,COUNT(ATTENDANCE) DAYS_WORKED
FROM (
SELECT EMPLOYEE_NAME,DATE,ATTENDANCE
FROM TABLE
WHERE ATTENDANCE = 'IN-OFFICE')
) B
ON A.EMPLOYEE_NAME = B.EMPLOYEE_NAME
You now have the Field DAYS_WORKED then just add it to your table.
=Count(Fields!EmployeeName.Value,"DataSet1")