How to get accumulated total in Netsuite saved search? - netsuite

I have a scenario where i have to take sum of a columns values in a linear fashion. I am using:-
SUM({custrecord_hm_bc_payroll_net_pay}) OVER(PARTITION BY {custrecord_advs_hold_unhold_status} ORDER BY {custrecord_hm_bc_payroll_emp_id} ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
Please suggest.

To use Oracle's analytic functions in a Netsuite Saved Search you need to trick the system by inserting a comment -
SUM/* comment */({custrecord_hm_bc_payroll_net_pay}) OVER(PARTITION BY {custrecord_advs_hold_unhold_status} ORDER BY {custrecord_hm_bc_payroll_emp_id} ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
Link

Related

Power Query - Alternative for Join to filter Records

I have two tables:
Table: One Row per Order with the Status (Online / Offline)
Table: Multiple Rows per Order
Now I would like to reduce the number of record/ rows in the second table based on the status (Offline) from Table 1.
Is there any alternative to a right join? The first table is filtered on Status 'Offline'
We are talking about several millions of rows which takes some time to Join.
Any thoughts on this from your sight?
Some thoughts:
Create a relationship between these two tables and filter to "Offline".
You could create a join (Merge queries) in Power query and only select the On/Off State column to append. Then the import needs more time, but you're getting a flat dataset in PowerBI
Create a new column in PowerBI with DAX and use LOOKUPVALUE
Without seeing the data I think I would try the first one. If it's too slow, the I think the only way is the second point. Even it takes some more time for importing.
The third one might be the slowest.

Can RANK or ROW_NUMBER be used in summarized Netsuite search results?

I apologize if this question is a duplicate. Most answers I see were not related specifically to Netsuite search format.
I need to rank a search result by sum of amount, grouped by item. I tried ROW_NUMBER() OVER (ORDER BY Amount) but it didn't work. Any advice? Is this even possible in summarized search results?
search results format photo
Any help would be greatly appreciated.
As you are aggregating the results (MIN, MAX, SUM etc) you also need to aggregate the expression in the ORDER BY clause, so that the results returned by the ROW_NUMBER() function match up with the summarized results of the rest of the saved search. All you would need to do is add a SUM() around {amount}:
ROW_NUMBER() OVER (ORDER BY SUM({amount}))

Removing irrelevalent data with power query

I have a situation where I have data in such format.
There are thousands of rows with such status. What I would like to have is a new table where rows 2 and 3rd are removed and only the bottom row is left for reporting.
Currently, I have a VBA macro code, in which it first concatenates [sales document and product], checks and tags for repeating value. For the tagged lines, concatenated value times billed price is matched with next (-1 * Concatenate next value * billed price) and both lines are deleted in a loop.
This operation takes a long time sometimes as the size of the file can be big. I would like to move to power query because I have other related files, transformation happening there.
Would be glad if anyone can help me.
BR,
Manoj
I would recommend doing a Group By on the first four columns and using Sum as your aggregation for the billing column. Then simply filter out the 0 rows.

How to invert a merge query in power query

I have a single column table of customer account numbers and a main table containing 400,000 records pulling from an access database. I want to remove all records from the table where the customer account number can be found in the single column table.
The merge query capability in power query allows me to return only the records where there is a match on the customer list (in addition to a variety of other variations on this theme) but I would like to know whether there is a way to invert this so that I return all records where the customer number does not appear in this list.
I have achieved this already by using the List.Contains function and adding a custom column to identify the rows to exclude and then filtering them out, but I think this is severely impacting the performance of my workbook. Refreshing the table that initially has 400,000 rows prior to this series of transformations takes a very long time, and all queries that depend on this table then also take a long time to refresh.
Thank you
If you do a Left Anti Join of your table with a single column, this will give you your table filtered to only have the rows which do not match to the single column.

how to calculate unique stores selling products in powerpivot

I'm not overly experienced with DAX, and my boss has asked me for some metrics which seem past my capability. Specifically, she wants to know in what percentage of the stores any item is being sold at.
We have a Stores table which is in a one to many relationship with the measures table relating by [STORE_ID]. The items table is also related 1-to-M to the measures table by [ITEM_ID]. the measures table contains which indicates among other things, the weekly [Sold] of an item.
My current logic has been to separate this problem into two more simple parts, (stores selling product)/ (total stores). finding the total stores which is an easy distinctcount in the stores table, the The next is more difficult. I tried Stores_Selling_Product = countrows(filter(filter(Measures, earlier(measures[ITEM_ID]) = measures[ITEM_ID]), EARLIER(Measures[STORE_ID]) <> Measures[STORE_ID])), but I found that only excluded the stores that matched the current store ID. Is there a way to exclude stores that have already been counted?
if it helps there is also a binary cell [SoldInStore] which is 1 if the item is sold in that store else 0. I'm pretty certain I'm going to have to use something other than countrows, but I don't know where to look. Any advice would super nice. Thanks in advance,
-Mudkip.
AllStores:=
COUNTROWS( ALL( 'Stores' ) )
StoresWithSales:=
COUNTROWS(
CALCULATETABLE(
'Stores'
,'Measures'
)
)
%StoresSelling:=
DIVIDE( [StoresWithSales], [AllStores] )
The first measure will always return the total number of stores in the 'Stores' table, regardless of any filter context from the pivot table.
The second utilizes the magic of cross table filtering to filter 'Stores' to only those rows that have at least one corresponding row in 'Measures' based on whatever filter context currently exist on 'Measures'. Think of it as essentially the same as the following in SQL:
SELECT
COUNT(1)
FROM Stores
WHERE EXISTS (SELECT
COUNT(1)
FROM Measures
WHERE Measures.StoreKey = Stores.StoreKey
AND <whatever filter context exists on Measures>
);

Resources