Saved search report in Netsuite - web-services

I want to create a report in Netsuite ERP that shows me the information about Departments Sales and Budget by Month. I think I can achieve this by creating a saved search that chooses this items, however I don't understand under which category I can find this fields. A saved search would be ideal as I am trying to authomatize the reports in a java application, and I discovered that I can call the savedSearch results.
I found the Department under the standard Criteria in the subcategory "Owner..." and I added a Date standard criteria with the values "within this month", however I have not found the group that contains all the Sales/Income/Margin or the budget (though, I found an aggregation sum function that may be used along with a field). I will appreciate any help. Also, will the addition of this fileds be enough to get the Sales X Department X Date information or do I have to use a different join method?
Thanks!

You'd have to combine two saved searches to achieve this.One on budgets for the period you need. The department column is available on the budgets saved search.
The other would be transactions for the period. Generally budgets are against posting transactions so Invoices, Cash Sales, Credit Memos and Cash Refunds would be in your other search. If you group those by Department you could then combine the two searches in code to create your own budget vs actuals report.

Related

Calculate difference between two dates in different tables not directly related in PowerBI

I need to calculate the time elapsed between to dates, in days. The values are the creation date and the payment date for every invoice in my model table. I will use this value to classify my invoices: sort by time passed, classyfy them, make a Pareto Chart... etc. So I need to create a calculated column in the inoice model table (can't imagine an approach using measures).
But I have two handicaps:
Tables ARE NOT DIRECTLY RELATED, so I can't use the RELATED function
The invoice can be paid in several installments
So, for each invoice, I need to calculate de time elapsed, in days, between the generation date (in a table) and the MAX payment date of all it's installments (in another indirectly related table)
This:
DaysElapsedInPayment = DATEDIFF(Invoices[InvoiceDate], Max(RELATED(Installments[InstallmentPaymentDate])), DAY)
would work if the tables were directly related an DateDiff whould accept MAX, but no, it's not the case. For your information, if could be usefull to you, this is my invoice-payment model scheme:
Could you help me, please?
EDIT:
As requested, I explain more deeply my data model...
My model looks complex because an invoice can be paid by several payments (part in cash, part in direct debit, for example), so a invoice can have MULTIPLE payments. At the same time, a payment can involve several invoices. Thats why my invoices-payments is many-to-many. And also, a payment (for example a payment by direct debit) can be divided in installments that are monthly sent to bank.
My model has lots of tables, not in english. For my purpose, I mock the needed ones here:
As you can see in the mocked data:
One invoice is paid in a single payment. It's the common case. We only have a single payment date in 'Payments'. That one is the one I need.
Another invoice is paid in TWO payments (part in cash, part payed by VISA), in different days. I need the date of the LAST of both payments.
Last case, I have two invoices that will be paid as a 'SINGLE' payment. Both should have to return the PaymentDate in Payments. But, at the las moment, we agreed with the client to pay them in installments. So installments are created, each one with a DueDate an the date wuere they were finally payed. So I need to get the LAST date of all installments for this payment.
It's complex, I know, but at the end, is about:
Given a value, find related values in anoter table indirectly related
From all values found, get the greatest
The function must perform theese operations, and put the results in a calculated column.
Have you triend creating a Calendar Table with the AUTOCALENDAR function? That way you could create a relation between both tables to make the calculations. Let me know if you need further assistance in order to add this table to the model

Power BI: Filter based on SUM

I have a horizontal bar visual where I’ve plotted the users with the highest sales.
It is "user name" vs "SUM(sales)" (user names and sales are in two different tables).
I’ve also used a filter as I only want to see users with SUM(sales)>1000€.
Now, on this page I want to put other visuals so that I can see information about this group of users, such as:
How many users are there?
What's the average age?
How many men and women?
and so on...
However, if I use a page level filter on sales, I can only filter a single sale value and not the sum for the user.
How can I filter the page based on a user’s total sales?
You could create a calculated column for a user’s total sales in your username table and then filter based on that.
Total Sales = CALCULATE(SUM(Table2[sales]))
There’re also solutions utilizing GROUP BY if you prefer that.

Showing Side by Side Measures from Semi-Related Tables in Power BI

I have a data model in Power BI that, among other things, has the following tables
Employees (Dimension; employee ID/name)
Jobs (Dimension; contains details about the job, including job ID)
Employee history- Contains a record for each day an associate was in a job(snapshot table);
Job Budget History- Contains a record for each day a job was budgeted(snapshot table)
Calendar Table
The table is modeled like so (simplified version):
In Power BI, I am trying to make a simplified table view that contains measures based on both the budget history as well as the employee history for the most recent day in the dataset (simple count rows/distinct count of calendar table)
However, attempting to do so gives me the results below if I try to put both measures on the table. Basically it appears to be doing a cross join between each table and matching associates with jobs they don't have (this happens when the budget is added).
Of course, if I just do one of the singular measures everything works perfectly. I am fairly certain it is because there is no real connection between the 'employee' and the 'budget history' in this relationship, so it is just joining everything on the date without any context.
I have tried several things such as making inactive relationships with userelationship(), using visual level filters etc. but I'm not sure what the best option in this situation would be. (I am trying to avoid bidirectional relationships if possible)
Ideally this information should show on this date that Joe was present as President, Sally was present as an operator, and the Manager position had nobody, but all three were budgeted.
Any advice is appreciated. I have attached a simplified mockup pbix file for reference.
PBIX File
This is a complicated problem for many reasons. I was able to produce this report:
by removing field "Name" from the table and replacing it a measure:
Employee Name =
CALCULATE(
SELECTEDVALUE(Employees[Name]),
CROSSFILTER(Employees[Employee_ID], Employee_History[Employee_ID], BOTH)
)
It looks exactly like the report you want, but if you have additional requirements, you'll need to make sure that such approach works for you.
If this is acceptable, a brief explanation:
the root cause of the issue is missing Employee-Budget relationship. When you put Name in the table as a filter, it doesn't propagate to the budget table and causes a cartesian product.
Removing Name from the table eliminates the need for the filter propagation, but then you won't see employee names. I solved this by pulling employee names with the measure, where required propagation is forced by CROSSFILTER function (essentially, it's like a temporary bi-directional relation only when you need it, so it does not negatively affect the rest of the model).

PowerBI / PowerQuery: Date slicer for multiple tables

Fellow PowerBI enthusiasts,
I am working on a reporting tool for our support team within our company. They would like to see the hours worked for each operator on a specific selection of dates. This could be just one day, or the whole week.
There are three different kinds of tasks that can be logged. Either time spent on Changes, on Incidents or on Operations (Change-, Incident- and OperationsActivityTimeRegistrations). There is a relationship between these registration tables and the operators table to show the full names in the PowerBI Dashboard, but there is one problem:
I cannot make a proper slicer for the dates. If I select one of the dates from a ___TimeRegistrations table, it will only filter on the dates for that table. That's why we made a new table called 'Datum' which contains all the dates from 1-1-2018 till 31-12-2019 and use those as input for my slicer, but I cannot make a link.
A picture of the relationships: https://imgur.com/a/eoB3rvE
A picture of the report: https://imgur.com/a/yhrACoV
Thanks in advance!
Kind Regards,
Sander

Building DAX Gateway Analysis formula

I need to build a formula in DAX that will show the number of customers who purchased again after their initial purchase, broken out by Product. I have a standard data warehouse with a Order Placed fact table, a Customer dimension table, and a Product dimension table. I am able to find the number of customers who purchased each product on their initial purchase by using this formula:
First Purchase Customer Count = CALCULATE(DISTINCTCOUNT(Demand[CustomerKey]),Demand[Customer Order Sequence Number] = 1)
My visual is a table with the Product as the only attribute, so this first formula is being calculated per Product. The next formula needs to count the number of customers who bought a second time, regardless of what Product they purchased that second time, but it should only include customers who purchased the current Product the first time. I have successfully created this formula to do it, but it usually errors out on the 1M row limit unless I filter the Product by subcategory.
Rebuyer Count = COUNTROWS(INTERSECT(SUMMARIZE(FILTER(Demand,Demand[Customer Order Sequence Number] = 1),[CustomerKey]),SUMMARIZE(CALCULATETABLE(FILTER(Demand,Demand[Customer Order Sequence Number] = 2),all('Product')),[CustomerKey])))
How can I improve this formula so it will run without bombing?
Old question, but on the off-chance that this is still an issue for you, have you reviewed the New and Returning Customers pattern on DaxPatterns.com? http://www.daxpatterns.com/new-and-returning-customers/
Your returning customers solution is creating a table of first-time customers, and then a table of second-time customers, and then joining those two tables together to count the number of first-time customers who are also a second-time customer.
The DaxPatterns solution is slightly different. Rather than calculating 2 potentially large tables of customers on the fly and then joining them, it is counting existing customers who have made a prior purchase.
You would need to adapt their solution to meet your requirements. They have a concept of Absolute Returning Customers (meaning the customer's first-purchase was for any product, and their second purchase was for the specific product you care about). You want the reverse of that (the customer's first-purchase was for a specific product, and their second purchase can be anything).
Overall, however, you'll have less bombing out if you start from a single list of first-time customers and filter out the customers you don't want (i.e. who never bought again) vs. compiling 2 separate lists of customers and intersecting them.
(It's the difference between letting everyone into the theatre, then throwing out everyone without a ticket, vs. checking tickets at the door and only letting people with a ticket in).