How to count the particular values in the field in Google Data Studio - google-data-studio

I am trying to create a simple table in Google Data Studio, which fetches data from MySql table. For example,
"Peter
John
Mike
Peter
George
Peter"
The above are the set of values in a field,
Here I have to count the number of "Peter" in the field and display the count.
Is it possible to display the count of particular values from a single field? If so, what function should I apply to get the required output?

I would suggest using a REGEXP_MATCH function to create a new field. Try this:
Create new field called Peter Count and use this formula:
CASE
WHEN REGEXP_MATCH(FIELD_NAME, "Peter") THEN 1
ELSE 0
END
Make sure the new field has a field type of Number and aggregation of SUM
Create a scorecard in your report and select your new field as the metric.
That should add up the occurrences of Peter and ignore other names.

Related

Identify elements that do not appear in the period (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.

Index match function with multiple criteria and duplicate values

I am trying to work my way out using index and match function (I am relatively new using this function)
I have a database with multiple criteria and also has duplicate values. I have 3 criteria for index and match
Salesman Name (duplicates in the field), month and value greater than 0. I have to select stores names based on the name of salesperson, month and value.
Outlet Name salesman Name Month Value
Outlet ABC Tom Jan 1
Outlet BCD Tom jan 2
Outlet XYZ Marc Feb 1
Outlet UTR Tom Mar 0
How can I use Index match function to select salesman "Tom" month "Jan" & value > 0
Note: Month, Salesman are fixed each row "to enter the salesman name & Month - input fields" however the value criteria is fixed at ">0"
Assuming that you just want to select the first outlet in the case of duplicates...
You can use INDEX/MATCH/INDEX to select based on multiple criteria:
=INDEX($A$2:$A$5,MATCH(1,INDEX(($B$2:$B$5=$F2)*($C$2:$C$5=$G2)*($D$2:$D$5>0),0),0))
This is essentially the same as a normal INDEX/MATCH, however, it uses a second INDEX to find the index where all the required criteria is true.
If you would like to return both outlets in the case of duplicates, I would suggest adding a helper column ("Outlet ID") and use a MINIFS formula to select each. Let me know if you need this suggestion clarifying.
EDIT: UPDATE BASED ON FURTHER COMMENTS
If I understand correctly, I think that you would like a table where you can input the salesman and month, and it spit out a list of Outlets where the value is >0.
Based on this, I think that your best bet would be to add a helper column to the list of data. This helper column with give each distinct outlet a unique ID:
=IF(
MINIFS($A$2:$A2,$B$2:$B2, $B3)=0,
MAX($A$2:$A2)+1,
MINIFS($A$2:$A2,$B$2:$B2,$B3)
)
This formula will check if an ID has already been assigned to the current outlet. If it has, it will use that one. If it hasn't, it will check what the MAX ID used so far is, and add 1 to it.
Now, we can use these IDs to produce a dynamic list of IDs associated with a particular Salesman/Month/Value:
The main formula here is the:
MINIFS($A$3:$A$7,$C$3:$C$7,$G$3,$D$3:$D$7,$H$3,$E$3:$E$7,">"&0,$A$3:$A$7,">"&MAX($G$6:$G6))
The rest is just to remove the zeros which are returned when we do not have any more IDs in out list.
The MINIFS formula selects the lowest ID where the salesman is the one we want AND the month is the one we want AND the value is >0 AND the ID is greater than any which already appear in our list.
Once we have our list of IDs, it is a simple matter to retrieve the name of the outlets using an INDEX/MATCH. We can then hide the IDs entirely if we wish.
=IFNA(INDEX($B$3:$B$7,MATCH($G7,$A$3:$A$7,0)),"")
The IFNA is just to prevent errors showing on empty lines. If you preferred, you could do something like this instead:
=IF($G7="","",INDEX($B$3:$B$7,MATCH($G7,$A$3:$A$7,0)))
Please let me know if you need me to expand any more.

Array formula having unique values for Data Validation dropdown without using helper column

I am trying to create an array defined name to enter into a data validation dropdown without using any helper columns in the sheet.
I have a table containing one of the column headers called 'List' which contains names of employees. The names may be duplicated, hence I want to extract only the unique names and put them into a data validation dropdown. I don't intent to use VBA and don't want to use any helper columns to drag the formula down to populate the unique names. On pressing F9, the formula should return unique values in an array like this:
{tom;fawad;george;jane;mario;flavia}
The table column looks like this:
List Column 2 Column 3 .....
tom
fawad
george
george
jane
mario
flavia
mario
george
fawad
Right now the formula is returning only one value when pressing F9 key.
=INDEX(list,IFERROR(SMALL(IF(FREQUENCY(MATCH(list,list,0),ROW(INDIRECT("1:"&COUNTA(list)))),ROW(INDIRECT("1:"&COUNTA(list))),""),ROW(INDIRECT("1:"&COUNTA(list)))),""))
I think it may require TRANSPOSE or SUBSTITUTE function to split the returned values across dropdown rows. Someone had demonstrated something like this, but I don't remember the link now.
Anyone know how to create a unique names array formula that I can simply enter directly into a Data Validation dropdown?

Vlookup array multiple columns

Excel wiz's,
I'm trying to build a report with a simple drop down list of names. Rather than try to explain in more detail, let me give you a sample dataset:
Table1:
Text Person1 Person2 Person3
String here contains name(s) Mike Smith Robert Johnson Suzy Q
Another string with name(s) Dan Boy John Michael Bob Wise
Different string with name(s) Robert Johnson Suzy Q
In my report sheet, I have a drop down list of all the possible "persons" that I want to chose from and then return all values from the "Text" column in an array. I have been able to make it work with only one column using this formula, where C4 contains my choice in the dropdown list:
INDEX(Table1[#All],SMALL(IF(Table1[Person1]=$C$4,ROW(Table1[Person1])),ROW(1:1)),1)
The text column will contain all the names of the Person columns, but they are in a different case (all caps, can't change format for display purposes). Maybe a SEARCH function would be more useful? I'm not sure. I'm trying to avoid using a macro, but I am not completely opposed.
Let me know what you guys think, and thanks in advance!
Simply re-organize your table so that there's one row per name... the V-Lookup on the name and get the matching list.
Person Text
Mike Smith String with names
Robert Johnson String with names
Suzy Q String with names
Dan Boy Second string with names
are you trying to make validations for teams? like select team, then next drop down gives only members of that team?
you can use offset inside validation. in one cell put a validation for the list of teams. in the other cell, create a list validation, use a offset formula to return the range of members based on the selected team.
edit: not sure how to put in a table, but this is how you would fill a range with vlookup
in the table with the entries, add a column with serial number starting from 1-n
just below the drop down box, enter numbers 1 to n in order
vlookup the serial number in the table, that is the row you are looking up
for the column, use a match to look in the table which column the current selected person is
drag the formula down to fill n numbers

issue trying to use combine value to get a value from a datasource

I have a summary report with a multiples dataset used in differents lookup, I know the lookup compare single values only, I need to compare double value in a datasets and return the value, I'm trying to using a combined source in a first parameter of lookup but I'm not sure if it will be work
dataset1
name team value
----------------
john team1 3
john team2 4
mark team1 2
jane team2 1
I want to use lookup for this dataset using name and team together to build a unique key and get the correct value like a
lookup for "john+team1" and get the value 3
Any help or idea???
Would it not be easier to compare the 2 datasets within SQL rather than trying to do it in SSRS? Temp table1 would be name etc
Write one massive query to combine all of the data, that was it's easier/ quicker to use and it can be used in one table

Resources