RunningCount webi Business Objects Formula - excel-formula

I am trying to produce a running count of salesid's for each distinct customer id.
I have tried this formula:
=RunningCount([Order ID])ForAll([Query 1].[Brand Account ID])
And unfortunately it yields this result:
We can see that where 'Count_of_Salesorder' == 12, it should have reset to 1 because the customer id has changed from B000115545 to B000159009
How can I achieve the running count of 'Order ID' for each distinct customer id? (Customer id is the field containing values that begin with 'B000')

You need to specify that you want the count to reset for each value of Brand Account ID.
=RunningCount([Order ID]; ([Brand Account ID]))
If you navigate to the RunningCount function with the Variable Editor and click on the "More on this function" link you will see its documentation.

Related

Showing Last Sold Date In a Netsuite ITEM Saved Search

I've created a search that shows current inventory on hand, their purchase price, and a formula that multiplies the two to have current value.
In the results field I want to have a column that shows the last time an item was on a sales order. but i am coming up short. Is there a way to do this?
Filter Criteria
Results Criteria
Criteria -
Inactive - FALS
Type - Inventory Item
Transaction Field: Type - Sales Order
Available - Is greater than 0
RESULTS -
Name - (Summary Type Group)
Description - (Summary Type Group)
Available - (Summary Type Count)
Transaction Fields - Date (Summary Type Maximum)
Did you create the saved search from the Item Record or Transaction Record?
If you created it from the Transaction Record then you will want to make sure to use the Date Field and Summary Type (Results tab) as Maximum.
Field = Date
Summary Type = Maximum
If you created the saved search from the Item Record you will need to use the Transaction Fields... table join to bring in the Transaction Date field.

NetSuite get transactions that do not contain items with specified attributes

I am attempting to create a list of open pending approval sales orders that do not contain items with specific values defined in a custom field. I am able to do this when the sales order contains only items that meet this criteria. However, when their are two items and one meets while the other does not my search is no longer valid.
I have two sales orders. Sales order 123 has a shipping method of Ground, while Sales order 321 has an item with Shipping method of Ground and shipping method of Freight. I expect to get only Sales order 123 returned.
I made this formula in criteria section:
CASE WHEN {item.custitem_shippingmethod} = 'Freight' Or {item.custitem_shippingmethod} = 'Free Freight' THEN 1 ELSE 0 END
but got both orders returned. I tried using the same formula in the summary criteria but that also did not work. Any suggestions?
Picture of Criteria in NetSuite
Thank you!
You could potentially use summary criteria. It's practical but it's not the cleanest looking search. You need to have a corresponding formula column in your results for it to work:
Group by Document Number.
Create a formula (Numeric) result column with summary type of Sum using your above formula.
Create a summary criteria of type formula (Numeric) with summary of type Sum
and use the same formula and set the value to be less than 0.
This will return only records that do not include those shipping
methods.
Alternatively, have you considered running the logic (workflow/suitescript) when the record is saved and storing a checkbox value such as "Does not include freight"? It would make searches based on that criteria easier.
For example if you store the ship method on the line, something like:
// Set your freight method indexes
var freightMethods = ['1','2']
var itemLinesCount = nlapiGetLineItemCount('item');
// If a line is found with one of the freight methods you're looking for then mark the record.
for(var i = 1; i < itemLinesCount; i++)
{
var shipMethod = nlapiGetLineItemValue('item', 'custcol_shipmethod', i);
if(freightMethods.indexOf(shipMethod) !== -1)
{
nlapiSetFieldValue('custbody_includes_freight', 'T');
break;
}
}
If you store the ship method only on the item record it can be a bit trickier to manipulate (due to the way Netsuite handles item record types).
Does the line being returned have a freight value or are you getting another line from the same order?

Concatenate each column value into a string for a subquery

All I've done a lot of background reading on this on and off for the past day or so and I'm none the wiser on how to achieve this.
I have looked on this site and found ways of concatenating multiple rows into one column however what I'm after is a bit more bespoke, please help...
I have two tables - one is a list of people and details about them such as name etc and a person reference.
The second contains a number of alerts about a person, one person can have multiple alerts. This would contain a person reference and the type of alert they have in a string.
I want to join these two tables using an inner join on the person reference.
I next want to find all of the alerts for each person and concatenate it into a string and show this as the "All alerts" column.
So I will end up with the following output:
First Name | Surname | All Alerts
-----------+---------+--------------------------
Tony | Stark | Alert 1, Alert 2, Alert 3
I can get as far as going through all of the alerts in the alerts table and put the alerts for every person into a string, obviously I need a concatenated value for each person, and haven't figured out how to do this.
I've spent a day on this and looked into XMLPath solutions and using CTE, CROSS APPLY and subqueries to specify the where clause. I am a little lost.
DECLARE #ConcatenatedVals VARCHAR (255)
SET #ConcatenatedVals =
(
DECLARE #AllAlerts VARCHAR(8000)
SELECT #AllAlerts = COALESCE(#AllAlerts + ', ', '') + personAlert
FROM Alerts
SELECT #AllAlerts AS 'All Alerts'
)
I found the solution for this posted here:
https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/#Toc205129480
This referenced a solution by Adam Machanic
Also, stuff is actually a function, not seen this before:
SELECT p1.CategoryId,
stuff( (SELECT ','+ProductName
FROM Northwind.dbo.Products p2
WHERE p2.CategoryId = p1.CategoryId
ORDER BY ProductName
FOR XML PATH(''), TYPE).value('.', 'varchar(max)')
,1,1,'')
AS Products
FROM Northwind.dbo.Products p1
GROUP BY CategoryId ;

Kentico - Form Control Drop-down List & SQL Query

I couldn't make the title clearer, but here's what I need help with.
I have a custom page type [1] for Leaders which includes 2 fields: Name, and Title. This holds the list of all leaders at the company.
I have another custom page type [2] for Speaking Events, which includes a field called Speaker to display the speaker's name and title. This field was set up as a drop-down list with data source from a SQL Query to query the Leaders data in [1].
Select LeadersID, Name, Title from co_leaders order by Name
I got it work fine - the drop-down displays a list of Name. However, what I wanted to display in the drop-down option is: Name, Title (not just Name) like below so that I only pick one and have both Name and Title. Is it possible to do this?
John Doe, CEO
Jane Doe, CFO
Hope it's clear and thanks for your input!
This is the SQL you are looking for:
SELECT LeadersID, Name + ', ' + Title FROM co_leaders ORDER BY Name
You need to do a concatenation of the column values (Name and Title), as opposed to selecting the columns separately.
EDIT: This is assuming that Name and Title are not nullable fields.
If there is a NULL value in any of the concatenated fields, the end value will be NULL. In this case, you will need to use COALESCE (or an equivalent function) to define an alternative value. For example:
SELECT LeadersID, Name + ', ' + COALESCE(Title, 'Member') FROM co_leaders ORDER BY Name

How to pass current date value into the bottom count

I was trying to get a worst performing product group for a selected date, using bottom count. My aim is to return the amount and not the dimension name. But the query is returning the bottom count based on the default date in the cube and not form the select query. Is there a way to pass the current date into the bottomcount? Below is the sample query which i was using:
with
member worst as
([Measures].[Amount])
set worstgrp as
BOTTOMCOUNT([Product].[Product].Members ,1 , [Measures].[worst])
member worstamount as
sum([worstgrp],[Measures].[Amount])
select
{[worstamount]} on 0,
([date].[date].[month-day].[18 Jul 2014]) on 1
from
[Full Details]
We can have multi select on date. And to be exact I am trying to create a calculated member in the cube and use that cube for an ad hoc report usinfg excel. So I guess we cannot pu the date in where clause, but only in select clause.
Just define your set as follows:
set worstgrp as BOTTOMCOUNT([Product].[Product].Members ,1 ,
sum(EXISTING [date].[date].Members, [Measures].[worst]))

Resources