Merge two similar records in Data Studio - google-data-studio

I have a table with two similar records in Data Studio and I want to aggregate them with other records.
Example:
SITE / VISITS
1- website.com / 4
2- website.com-cdn-ampproject / 6
3- othersite.com / 4
How can I sum the first 2 of them and them show the other records?
Thanks! :)

Related

Snowflake Date range query for historical data and add a delta

I am new to Snowflake SQL and writing a requirement to get historical dashboard.
Requirement is to get the data 5 years from current data + want to include the whole of the first month of the past 5th year. For example if today is 26-05-2021, we would need to get the data from
01-05-2016 to 25-05-2021.
Using my present Snowflake SQL query, I get the data of last 5 years, is it possible in Snowflake inbuilt to get the delta of remaining days.
select * from table where portion_start >= trunc(add_months(sysdate(),-12*5),'YEAR')
I believe this is what you are looking for:
select *
from table
where portion_start >= dateadd(year,-5,date_trunc(month,current_date()))

Need to add dynamic columns in headers in SSRS report

I need to add column headers in SSRS report but that are dynamic in nature.
For example, sometimes Query will return 5 different named columns with it's data and sometime will return 9 different named columns with it's data and so on.
So how to drag or refresh columns in Dataset and how to show in SSRS report dynamically.
I am totally confused seen many articles but not able to get solution.
How to implement this in SSRS report. I have the query, depending on parameters columns gets generated. Check below sample report preview
its showing date in different columns
In SSRS , the dataset must always return the same number of columns with the same names and datatypes, so you cannot of what you want directly.
You have two options.
Option 1
Normalise the data.
So instead of returning something like
SomeID ColumnA ColumnB ColumnC
1 10 20 30
2 15 25 35
3 100 200 300
You need to return
SomeID ColName Amount
1 'ColumnA' 10
1 'ColumnB' 20
1 'ColumnC' 30
2 'ColumnA' 15
2 'ColumnB' 25
2 'ColumnC' 35
3 'ColumnA' 10
3 'ColumnB' 200
3 'ColumnC' 300
Once you have your data in this format, you can simply use a matrix in your report. Set the rowgroup to SomeID, set the Column Group to ColName and the data value to Amount
This is by far the simplest solution.
Option 2
Deconstruct and rebuild the table in code
There are several drawbaks to this method but if you are interested, read my answer to this question asked a few days ago
SQL Server - SSRS - Display the content of a Table/View directly in the report (and not using table/matrix)

MS Access - Color cells in a query that has the same numbers in a specific column

In my database i have columns with information that are match togheter with a column named MsgNumber this column looks like this:
Where if it´s 1 1 the two rows have some coherent information. 2 and 3 3 3 and 4 4 4 4 and so forh all the rows are aligned that way. My goal is to get the query to order the cells by color as show in the next pictur:
I tried with condition formation but then i needed to do a seperate "report" i need to edit the rows directly in the query. (doing it manually is not an option). Can it be done? Thanks

How to create the value I want by combining two pivot tables

I have combined two datas which are price 2013 and volume 2013 to create one pivot table. But how can I find revenue (Volume multiply price) by using pivot table? Please help. Thanks. My column field there included Price from data 1 and volume from data 2.
Switch one of the fields to Σ Values (Volume would seem to be the more sensible) and add a Calculated Field (PivotTable Tools, Options > Tools - Formulas) say Named: Revenue and with Formula: Volume*Price.
However depending upon your version of Excel and your data, you may receive incorrect results (eg in the GT row for revenue).

Access Report / SQL DCount function

I have the following Tables and Fields in my DB:
tblProductionRecords:
pk_fldProductionRecordID,
fk_fldJobNumber_ID,
fldPartsCompleted,
tblJobs:
pk_fldJobID,
fldJobNumber
tblEmployee_ProductionRecord:
pk_fldEmp_ProdRec,
fk_fldProdRec_ID,
fk_fldEmployee_ID,
fldHours
tblEmployees:
pk_fldEmployeeID,
FldName
So what I am tracking is production records for a given job. The pieces of the production records are:
Part Quantities.
Which employee(s) were in involved with completing the quantities (it could be 1 or more employees, hence the Many to Many relationship between employees and production records)
And how many hours each employee spent completing the quantities.
The problem I am faced with is tracking my total quantities for a job on my report. When a given production record has ore that one employee that worked on those quantities, the quantities are added for each employee record. So lets same 3 employees work on a job and the 3 of them created completed 1000 parts. In my report, it will show a total of 3000 completed.
I understand creating groups, footer, headers, running sums and the Count function (I believe).
What I suspect I need is a field in my Query that is a sum of how many records are in tblEmployee_ProductionRecord where fldProdRec_ID = "the current production record" in the detailed section. With that number I can divide the total completed quantities between the 3 (or how ever many) employees and do a sum of that field.
I hope this is clear enough. I and sincerly appriciate any help!
David
If I understood you correctly, your example (3 employees work on a job and each one created 1000 parts) will look like this in the tables:
tblEmployee_ProductionRecord:
pk_fldEmp_ProdRec fk_fldProdRec_ID fk_fldEmployee_ID fldHours
1 1 1 5
2 2 2 5
3 3 3 5
tblProductionRecords:
pk_fldProductionRecordID fk_fldJobNumber_ID fldPartsCompleted
1 1 1000
2 1 1000
3 1 1000
If yes, try the following query:
SELECT
tblProductionRecords.fk_fldJobNumber_ID,
Count(tblEmployee_ProductionRecord.pk_fldEmp_ProdRec) AS EmployeeCount,
Sum(tblProductionRecords.fldPartsCompleted) AS CompletedSum
FROM
tblEmployee_ProductionRecord
INNER JOIN tblProductionRecords ON tblEmployee_ProductionRecord.fk_fldProdRec_ID
= tblProductionRecords.pk_fldProductionRecordID
GROUP BY
tblProductionRecords.fk_fldJobNumber_ID
HAVING
tblProductionRecords.fk_fldJobNumber_ID=1;
This will return the following result:
fk_fldJobNumber_ID EmployeeCount CompletedSum
1 3 3000
--> for Job number one, three employees created a total of 3000 parts.
Is this what you wanted?

Resources