Identify elements that do not appear in the period (Google Data Studio) - google-data-studio

I have a table that shows the recurrence of purchasing a product, with the columns: product_id, report_date, quantity.
I need to list in a table the products that are more than 50 days unsold. The opposite I managed to do (list those that were sold in the last 50 days) but the opposite logic has not yet been able to implement.
Does anyone have any tips?
An example of the table:
product_id,date,report_date,quantity
329,2019-01-02 08:19:17,2019-01-02 14:34:12,6
243,2019-01-03 09:19:17,2019-01-03 15:34:12,6
238,2019-02-02 08:19:17,2019-03-02 14:34:12,84
170,2019-04-02 08:19:17,2019-04-02 14:34:12,84
238,2019-04-02 08:19:17,2019-04-02 14:34:12,8
238,2019-04-02 08:19:17,2019-04-02 14:34:12,100
238,2019-08-02 08:19:17,2019-08-02 14:34:12,100
238,2019-10-02 08:19:17,2019-10-02 14:34:12,100
170,2020-01-02 08:19:17,2020-01-02 14:34:12,84
170,2020-01-02 08:19:17,2020-01-02 14:34:12,84

There are many steps to do this task. I assume the date column is the one to work with. Your example from table includes duplicated entries. Is it right that at the same time the order is there twice?
So here are the steps:
At first add an calculated field date_past to your dataset:
DATE_DIFF(CURRENT_DATE(),date)
To the dataset add a filter SO_demo with:
include date_past<30
Then blend the data with it self. Use product_id as Join key. Only the 2nd dataset has the SO_demo filter. Add to the dimension of this dataset the calculated field sold_last_30_days with the formula "yes".
In the table/chart to display add a filter on the field include sold_last_30_days is Null.

Related

I want to apply, to a whole column, a formula that is already an arrayformula

I have a ledger with a bunch of expenses listed by date, category, and amount.
Expenses ledger
Separately I have an analytics sheet for one category, "Gas". I want the analytics sheet to show total gas expenditures month by month without having to update anything other than the ledger.
I can get a list of unique months with this formula:
=UNIQUE(ARRAYFORMULA(DATE(YEAR('Main Ledger'!A2:A), MONTH('Main Ledger'!A2:A), 1)))
This populates the months the way I want, and the list will automatically grow with the ledger. I put these in column A.
For each month, I want to compare every entry in the ledger against the date in column A and the category "Gas". I can do that for a single month with the following formula in column B:
=ArrayFormula(SUMIFS('Main Ledger'!D$2:D,MONTH('Main Ledger'!A$2:A),MONTH(A2),YEAR('Main Ledger'!A$2:A),YEAR(A2),'Main Ledger'!F$2:F,"Gas"))
Gasoline analytics
Because I have to use arrayformula to make the date comparison on the ledger, I'm having trouble figuring out how to then use arrayformula to automatically apply this monster formula to all of column B. As column A grows (automatically because of UNIQUE, I want column B to grow too.
I do not want to prepopulate column B and have a bunch of zeroes lying around, mainly because I will be using columns A and B to populate a chart.
try in one go:
=QUERY({Sheet1!A2:D},
"select month(Col1),sum(Col4)
where Col4 is not null
group by month(Col1)
label month(Col1)'month'")
update:
=INDEX(ARRAY_CONSTRAIN(QUERY({TEXT(Sheet1!A2:A, "mmmm"), Sheet1!A2:D},
"select Col1,sum(Col5),month(Col2)
where Col5 is not null
group by month(Col2),Col1
label Col1'month'"), 9^9, 2))

SQL syntax to calculate total menu items per meal orderID across multiple meal orderIDs

I am new to SQL and Stack overflow and have a question about SQL Server syntax. i have searched online but I am not finding what I need and I would appreciate your assistance in this matter.
I have data in a source table for meal orders (each with a specific ID (e.g. 12345C) and items of each order (e.g. sandwich, drink, chips), each with an associated number starting with 1. For instance, the sandwich would have an item number of 1, the chips would be item # 2, and the drink would be item # 3 for the same orderID 12345C. The prior example would therefore have 3 rows of data in the source table for orderID 12345C.
My questions are these:
how do I use a SQL expression to determine the number of items per each order (e.g. 3 for the above example, which is also the maximum value for item number for each orderID)
and then add all of these items per order across hundreds of orders per day to determine the daily total number of items ordered.
So, if I had 3 orders in one day - one with 2 items, the second with 3 items, and the third with 4 items, I would like my final number to be 9.
This number is for use in a Sisense dashboard that allows SQL syntax in the field definition. Thank you for your help!
It is a bit difficult to explain but I am not able to use a query from a table because I am working with a dashboard in Sisense so I am adding fields in a pivot display and one of the fields I would like to include is the total count of order items per day (across several dozen orderIDs).
Here is an example of the data in the table: from the example I would like the final answer for orderID 1787588 to be 3 (there are 3 items within the order).

Excel quartile function with variable array criteria (like countif)

hoping someone can help with my Excel query.
I want to use the quartile function (or similar, could use percentile if that's easier). I have data in a column but I want to limit the data I use from that column.
I have job departments in column A, people's salaries in column B (and other data in the other columns e.g name).
I want to use my one main data list (c. 2,000 rows) to pick out the quartiles for the 10 or so depts I have but I don't want to have to make 10 specific lists to calculate the quartile of each dept.
Is there an option to use a countif or similar function so that I can have a drop down list of my 10 depts and depending on what dept I select my summary table will show the quartiles relevant for just that dept?
Thanks
Use an array formula =quartile(if(A1:A1000=C2,B1:B1000),.75) press control + shift + enter after entering the formula. Note: C2 = the department which quartile you are calculating.

Birt report : How to hide in's and out of the table value in Birt Report

I have a following employee table value as below :
name | cost
john | 1000
john | -1000
john | 5000
when we add the cost column total will be 5000.
I need to print only the 3rd row in BIRT report, since the 1st and 2nd row get cancelled out each other.
I'm stuck at filtering the table for above scenario.
Couldn't you just solve this using SQL like
select name, sum(cost)
from employee
group by name
order by name
?
Or do you just want to exclude two rows if they have exactly the same cost, but with different signs? Note that this is actually something different, take for example the three rows [ john|1, john|2, john|-3 ]? In this case, a pure SQL solution can be achieved using the SQL analytic functions (at least if you are using Oracle).
Elaborate your question. Its not clear if these are columns or rows.
If These are columns:
Create a computed column in your dataset
In Expression builder of that column add/sub values using dataSetRow['col1'] and dataSetRow['col2']
Add only that computed column to your table.
If these are rows
Select rows you don't want to print
Go to properties tab
Find Visibility property and click on it
Check Hide Element option

How to add an non aggregated column in a fact table?

I'm working on a SSAS cube to allow user to analyze some sales.
So, I created a fact table to record all sales and few dimensions to browse inside data (category / location & store, etc...).
This is a example of the fact table output (from SQL Server Management Studio) :
When I browse my cube, I can review all sales including date, quantity, etc.
However, when I add some fields like the "unit price" or the "unit cost", it returns me a strange result probably due to an aggregate behavior.
It seems it return the sum of all matching rows (aggregateFunction property).
How to simply display the unit price of a sale without apply any calculation to the unit price column. The None value for the AttributeFunction display BLANK/NULL.
If your unitCost and unitPrice are the same for each product (I mean unitCost can be only 77.6 for product_id = 2), you can just use average (or even emulate average by SUM/COUNT) - but only for product dimension on axis!
Another dimensions will show real average values.
Maybe it's better to use this 'static' fields like attribute properties in 'Product' dimension? But you still need to add some logic to choose one value for several (or all) product members selected.

Resources