Custom Acumatica report variable not working consistently - variables

in Acumatica, the out of the box GL report" lists gl beginning balance, debits, credit and ending balance by Account / Sub-Account. MY client is requesting that a new sub-total be added at the end of each account that totals for the account, i.e. if there are 3 sub-accounts on a single account, they are requesting the beginning balance, total debits, total credits and ending balance for the ACCOUNT.
I added a new Account group above the account/sub-account group and added variables for the beginning balance, debits and credits and ending balance.
the debit, credit and ending balance variables work perfectly, and SOMETIMES the beginning balance at the Account level is correct, but often the beginning balance variable is multiplied by the number of transactions at the account/sub-account level.
for instance, the beginning balance of account 10000-00-00 for 12-2021 is 9133.07, there are 3 pages of transactions and the beginning balance, debits, credits and ending balance in the Account group footer are correct, BUT for account 12080-00-00 the beginning balance is 1,063,150.46 and what is printing in the group footer for this account is 4,263,486.84 which is the actual beginning balance * 4 and there are 4 transactions in this account.
in the asset and liability section there are about 150 accounts, and this incorrect beginning balance shows up on only 4 accounts for period 11 and 12 of 2021. it does happen a LOT more on income statement accounts, and in other periods.
Because the variable DOES work sometimes but not others I THINK I have created the variable correctly, but I am not finding much support for variables.
Acumatica support was unable to help with this issue and suggested I post on Stack Overflow.
I have attached the logic for the variable itself as well as the variable I “copied”.
with the exception of the =$SignBal*, which if added to the $AcctBegBal always returns a 0 (if THAT is the issue I would expect the beginning balance to ALWAYS be incorrect)
$BegBalance variable logic - works at group footer AccountSubaccount
=$SignBal * Sum(IIF(Prev([GLHistoryByPeriod.BranchID]) <> [GLHistoryByPeriod.BranchID], IsNull(
IIF([HistoryLast.FinPeriodID] = [#StartPeriod],
IIF(#UseMasterCalendar = True, [HistoryLast.TranBegBalance], [HistoryLast.FinBegBalance]),
IIF(#UseMasterCalendar = True, [HistoryLast.TranYtdBalance], [HistoryLast.FinYtdBalance]))
, 0), 0))
$AcctBegBal variable logic (works sporatically at group footer Account )
=Sum(IIF(Prev([GLHistoryByPeriod.BranchID]) <> [GLHistoryByPeriod.BranchID], IsNull(
IIF([HistoryLast.FinPeriodID] = [#StartPeriod],
IIF(#UseMasterCalendar = True, [HistoryLast.TranBegBalance], [HistoryLast.FinBegBalance]),
IIF(#UseMasterCalendar = True, [HistoryLast.TranYtdBalance], [HistoryLast.FinYtdBalance]))
, 0), 0))
Thank you in advance for any help or guidance offered!
Terrie

Related

How to calculate a bank's deposit growth from one call report to the next, as a percentage?

I downloaded the entire FDIC bank call reports dataset, and uploaded it to BigQuery.
The table I currently have looks like this:
What I am trying to accomplish is adding a column showing the deposit growth rate since the last quarter for each bank:
Note:The first reporting date for each bank (e.g. 19921231) will not have a "Quarterly Deposit Growth". Hence the two empty cells for the two banks.
I would like to know if a bank is increasing or decreasing its deposits each quarter/call report (viewed as a percentage).
e.g. "On their last call report (19921231)First National Bank had deposits of 456789 (in 1000's). In their next call report (19930331)First National bank had deposits of 567890 (in 1000's). What is the percentage increase (or decrease) in deposits"?
This "_%_Change_in_Deposits" column would be displayed as a new column.
This is the code I have written so far:
select
SFRNLL.repdte, SFRNLL.cert, SFRNLL.name, SFRNLL.city, SFRNLL.county, SFRNLL.stalp, SFRNLL.specgrp AS `Loan_Specialization`, SFRNLL.lnreres as `_1_to_4_Residential_Loans`, AL.dep as `Deposits`, AL.lnlsnet as `loans_and_leases`,
IEEE_DIVIDE(SFRNLL.lnreres, AL.lnlsnet) as SFR2TotalLoanRatio
FROM usa_fdic_call_reports_1992.All_Reports_19921231_1_4_Family_Residential_Net_Loans_and_Leases as SFRNLL
JOIN usa_fdic_call_reports_1992.All_Reports_19921231_Assets_and_Liabilities as AL
ON SFRNLL.cert = AL.cert
where SFRNLL.specgrp = 4 and IEEE_DIVIDE(SFRNLL.lnreres, AL.lnlsnet) <= 0.10
UNION ALL
select
SFRNLL.repdte, SFRNLL.cert, SFRNLL.name, SFRNLL.city, SFRNLL.county, SFRNLL.stalp, SFRNLL.specgrp AS `Loan_Specialization`, SFRNLL.lnreres as `_1_to_4_Residential_Loans`, AL.dep as `Deposits`, AL.lnlsnet as `loans_and_leases`,
IEEE_DIVIDE(SFRNLL.lnreres, AL.lnlsnet) as SFR2TotalLoanRatio
FROM usa_fdic_call_reports_1993.All_Reports_19930331_1_4_Family_Residential_Net_Loans_and_Leases as SFRNLL
JOIN usa_fdic_call_reports_1993.All_Reports_19930331_Assets_and_Liabilities as AL
ON SFRNLL.cert = AL.cert
where SFRNLL.specgrp = 4 and IEEE_DIVIDE(SFRNLL.lnreres, AL.lnlsnet) <= 0.10
The table looks like this:
Additional notes:
I would also like to view the last column (SFR2TotalLoansRatio) as a percentage.
This code runs correctly, however, previously I was getting a "division by zero" error when attempting to run 50,000 rows (1992 to the present).
Addressing each of your question individually.
First) Retrieving SFR2TotalLoanRatio as percentage, I assume you want to see 9.988% instead of 0.0988 in your results. Currently, in BigQuery you can achieve this by casting the field into a STRING then, concatenating the % sign. Below there is an example with sample data:
WITH data as (
SELECT 0.0123 as percentage UNION ALL
SELECT 0.0999 as percentage UNION ALL
SELECT 0.3456 as percentage
)
SELECT CONCAT(CAST(percentage*100 as String),"%") as formatted_percentage FROM data
And the output,
Row formatted_percentage
1 1.23%
2 9.99%
3 34.56%
Second) Regarding your question about the division by zero error. I am assuming IEEE_DIVIDE(arg1,arg2) is a function to perform the division, in which arg1 is the divisor and arg2 is the dividend. Therefore, I would adivse your to explore your data in order to figured out which records have divisor equals to zero. After gathering these results, you can determine what to do with them. In case you decide to discard them you can simply add within your WHERE statement in each of your JOINs: AL.lnlsnet = 0. On the other hand, you can also modify the records where lnlsnet = 0 using a CASE WHEN or IF statements.
UPDATE:
In order to add this piece of code your query, you u have to wrap your code within a temporary table. Then, I will make two adjustments, first a temporary function in order to calculate the percentage and format it with the % sign. Second, retrieving the previous number of deposits to calculate the desired percentage. I am also assuming that cert is the individual id for each of the bank's clients. The modifications will be as follows:
#the following function MUST be the first thing within your query
CREATE TEMP FUNCTION percent(dep INT64, prev_dep INT64) AS (
Concat(Cast((dep-prev_dep)/prev_dep*100 AS STRING), "%")
);
#followed by the query you have created so far as a temporary table, notice the the comma I added after the last parentheses
WITH data AS(
#your query
),
#within this second part you need to select all the columns from data, and LAG function will be used to retrieve the previous number of deposits for each client
data_2 as (
SELECT repdte, cert, name, city, county, stalp, Loan_Specialization, _1_to_4_Residential_Loans,Deposits, loans_and_leases, SFR2TotalLoanRatio,
CASE WHEN cert = lag(cert) OVER (PARTITION BY id ORDER BY d) THEN lag(Deposits) OVER (PARTITION BY id ORDER BY id) ELSE NULL END AS prev_dep FROM data
)
SELECT repdte, cert, name, city, county, stalp, Loan_Specialization, _1_to_4_Residential_Loans,Deposits, loans_and_leases, SFR2TotalLoanRatio, percent(Deposits,prev_dep) as dept_growth_rate FROM data_2
Note that the built-in function LAG is used together with CASE WHEN in order to retrieve the previous amount of deposits per client.

SSRS Charts: Issues filtering data from a dataset

I am attempting to create a line (possibly column) chart on an SSRS report that compares ticket sale revenue versus TV ad expenses, by week, within 8 weeks of an event. I have attempted to use 2 different data sets, but was never able to get it to work. Instead, I combined both datasets into one with the following columns:
weeks_out - number of weeks out from event
tickets - total tickets or # of ad spots for TV ads
revenue - total ticket revenue or total ad expenses for week
category - "Ticket Sale" or "TV Cable"
I create the chart using revenue as my series and weeks_out as the Category Groups. If I provide no filters, it would just simply sum the ticket revenue and ad expenses together. I changed the series expression from SUM(Fields!revenue.Value) to IIF(Fields!category.Value = "Ticket Sale", Fields!revenue.Value, 0), and it worked just fine displaying weekly ticket revenue without the ad expenses added in. However I tried the following IIF statements to get TV Cable to display and all it would display is 0s for every week:
IIF(Fields!category.Value = "TV Cable", Fields!revenue.Value, 0),
IIF(Fields!category.Value <> "TV Cable", 0, Fields!revenue.Value),
IIF(Fields!category.Value <> "Ticket Sale", Fields!revenue.Value, 0),
IIF(Fields!category.Value = "Ticket Sale", 0, Fields!revenue.Value)
I have tried displaying the raw data in a table and that worked fine and IIF statement filters worked on it as well. At this point I can't quite figure out what is wrong with my data or the way I am setting up the chart that would make the ticket sales always work but the ad expenses never work on their own.
Edit: It appears to be the order that the data is being presented might be causing part of the issue. The query I wrote defaults to display the ticket sales first. I edited the query to display the TV Cable category first. Now when I add a conditional statement, the ad expenses show fine, but the ticket sales will not display by themselves.
I think you just need to SUM your expression, otherwise you're only seeing the value from the first record.
=SUM(IIF(Fields!category.Value = "Ticket Sale", 0, Fields!revenue.Value))
I tried to just add this as a comment but the commenting (and other things) don't seem to be working.

NetSuite Saved Search - Cash Transactions excluding Line of Credit Sweep Deposits

My goal is to show the sum of cash debit transactions excluding line of credit deposits (i.e. sweep transactions from the line of credit). I can isolate cash transactions but have had difficulty excluding transactions that have a debit to the cash general ledger account and a credit to the line of credit general ledger account. Any help would be appreciated.
The deposits from the line of credit account are posted as an "Other Deposit" type, which translates to {type} = 'deposit'; {version} = '2'. However, NetSuite will not let me include {version} as a criteria filter or in the results.
I was able to generate a search that is permissible but not an exact answer to my original question.
The information below describes the Cash In version of the Search. There are two searches that correspond to the answer. A Cash In and a Cash Out search. They show cash received or disbursed each week, but net out sweeps to and from the line of credit. In fact, the searches show the debit and credit associated with the sweep transactions, which is not ideal. So, in the details of the search results you will see a positive (debit) amount and the same negative (credit) amount, which when added together, net to zero. So the assumption is that all debits and credits to and from the line of credit equal one another. It is not perfect, but it will work for now and at least clearly show the assumption made, to the end user of the searches.
The end goal was to use the searches as KPIs (i.e. a single total value on a NetSuite dashboard for cash received and then cash disbursed.
This is the NetSuite Saved Search Criteria and Results for the Cash In version:
Criteria:
Account is Cash, Short Term Liabilities
Posting is True
((Account is Cash AND Amount(Credit) is Empty) OR
(Account is Short Term Liabilities AND Amount(Debit) is Empty))
Results:
Date
Transaction Name
Name
Memo
Account
Formula(Numeric)
-Summary Type: Sum
-Formula: CASE WHEN {debitamount} >= '0' THEN {debitamount} ELSE ({creditamount} * '-1') END

Microsoft Access query to retrieve random transactions with seemingly impossible criteria

I was asked to assist with developing a report to retrieve a 25% sample of random transactions within a specific date range. I am not a programmer but I was able to devise the following fairly quickly:
SELECT TOP 25 PERCENT account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data, log.to_data, log.tran_id, log.init
FROM account INNER JOIN log ON account.ACCT = log.ACCT
GROUP BY account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data, log.to_data, log.tran_id, log.init
HAVING (((log.DATE) Between #2/7/2018# And #6/15/2018#) AND ((log.action_txt)="mod" Or (log.action_txt)="del") AND ((log.init)="J1X"
ORDER BY log.tran_dt
This returns 25% of the records within the date range. Each record row is unique but each account number potentially has multiple records on each day. In some cases the records have the same date and tran_id as well.
Upon further discussion with the requester, he actually wants to see all of the transactions for 25% of the accounts that have activity on each day within the date range. Thus if there were 100 accounts on 3/1/2018 with records in this table, he wants to see all of the transactions for 25 of those accounts; if there were 60 accounts on 3/2/2018 with records in this table, he wants to see all of the transactions for 15 of those accounts; and so on.
I was thinking that an Access module would work best in this scenario as I believe there are multiple parts to this. I figured that I need a function to loop through the date range and for each day:
1. Count the account numbers only one time
2. Return all of the transactions for 25% of the total accounts
But as I mentioned, I am not a programmer and I am exhausted from searching possible solutions for the many parts.
I think the key to your question is that you only really need a pseudo random selection of results for your report. So you can force the Random number generator to reorder your results based on a value in the record and the current time.
Something like this should work - I assume your actiontxt field is a text field and pull out the length of each field and apply that to current date/time to create a pseudo random number that can be sorted.
All I really do is change your ORDER BY line
See if this works for you
SELECT TOP 25 PERCENT
account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data,
log.to_data, log.tran_id, log.init
FROM account
INNER JOIN log ON account.ACCT = log.ACCT
GROUP BY account.CID, account.ACCT, account.NAME, log.DATE, log.action_txt, log.field_nm, log.from_data, log.to_data, log.tran_id, log.init
HAVING (((log.DATE) Between #2/7/2018# And #6/15/2018#) AND ((log.action_txt)="mod" Or (log.action_txt)="del") AND ((log.init)="J1X"
ORDER BY Rnd(CLng(Now()*Len(log.action_txt))-(Now()*Len(log.action_txt)));
Modified similar idea from other StackOverflow question and response

Power Pivot / DAX - Add column that flags all entries for customers who meet criteria in any of their rows

I have a large database (2 million rows). There are many columns but the two relevant ones are CustomerID and AccountType. A customer can have more than one account type and if they do this will show as different rows in the database. If any of a customers accounts are AccountType = Premium, then they are a Premium customer.
I want to add a column in PowerPivot that will state whether a customer is Premium or not. So for example:
CustomerID Account Type Custom Column
1 Basic Premium
2 Deposit Not Premium
3 Savings Not Premium
1 Premium Premium
So in my example because customer 1 has a Premium account in the last row, the first row is also flagged as Premium. To make it one step trickier, there are actually a few codes, so it could be Premium1, Premium2 etc.
I think I could do this by creating a separate table and linking the two, but I would prefer to avoid this step if possible to keep the file size down.
Try this in the expression for the calculated column:
Custom Column =
IF (
COUNTROWS (
FILTER (
Table,
[CustomerID] = EARLIER ( Table[CustomerID] )
&& [Account Type] = "Premium"
)
)
> 0,
"Premium",
"Not Premium"
)
It is not tested but should work, let me know if this works for you.