DAX formula in Sql Server Analysis Services - formula

I am new to DAX, How can I calculate the runs of a particular player from below table. My table name PlayersData. For example, want to the total runs of the sachin tendulkar from the table. Need Dax formula..
I tried this for getting the occurrences of virat Kohli in the table:
:=COUNTROWS(VALUE(PlayersData[Name] = "Virat Kohli"))
But , it shows the Error..
Thanks in advance...

Finally the Query given my required result:
TotalRunsOfKohli:=CALCULATE(SUM('Players Data'[Runs]),'Players Data'[Name]="Virat Kohli")

Related

PeopleSoft Query Manager - 'count' function

I'm using the current version of PeopleSoft and I'm using their Query manager. I've built a query that looks at the job table and a customized version of the job table (so I can see future hires). In order to do this I've created a union. Everything works fine, except now I want to do a count of the job codes.
When I put in a count, I get an error. I don't know how to get it to work properly. I also don't really know how to using the 'having' tab.
I've attached some screenshots, including the SQL code.
SQL:
Having tab
You have a criteria in your query:
AND COUNT(*) = A.JOBCODE
Your job codes are string values that uniquely identify a job. It will never be equal to a count.
If you remove that criteria, your query will work:
The bigger issue is, what do you want to count? If your query was simply:
SELECT DEPTID, JOBCODE, COUNT(*)
This will give the count of employees in this department and job code. In your description, you said that you wanted the count of job codes. But each row has JOBCODE on it. The count of job codes on the row is one. What do you really want? The count of job codes in the database? The count of job codes in the result set?
If you want to get anything other than the count of rows within the group, you are not able to put that logic in PeopleSoft Query. You will need to create a view in AppDesigner and then you can add that to the query.

AWS dynamoDB - Why User and System errors not populating for each table instead of account metrics?

How to get the errors count for each table to get deep into it?
Usually errors (User & System error) occurs in each DynamoDB table but why it's categorized as 'Account metrics' in Cloud-Watch. So the value is the aggregate of all tables errors in that particular region instead table wise.
Thanks in advance.
Regards,
Garry.

Difference in statistics from Google Analytics Report and BigQuery Data in Hive table

I have a Google Analytics premium account set up to monitor the user activity of a website and mobile application.
Raw data from GA is being stored in BigQuery tables.
However, I noticed that the statistics that I see in a GA report are quite different the statistics that I see when querying the BigQuery tables.
I understand that GA reports show aggregated data and possibly, sampled data. And that the raw data in Bigquery tables is session/hit-level data.
But I am still not sure if I understand the reason why the statistics could be different.
Would really appreciate it if someone clarified this for me.
Thanks in advance.
UPDATE 1:
I exported the raw data from Bigquery into my Hadoop cluster. The data is stored in a hive table. I flattened all the nested and repeated fields before exporting.
Here is the hive query that I ran on the raw data in the Hive table:
SELECT
date as VisitDate,
count(distinct fullvisitorid) as CountVisitors,
SUM(totals_visits) as SumVisits,
SUM(totals_pageviews) AS PVs
FROM
bigquerydata
WHERE
fullvisitorid IS NOT NULL
GROUP BY
date
ORDER BY
VisitDate DESC
A) Taking February 9th as the VisitDate, I get the following results from this query:
i) CountVisitors= 1,074,323
ii) SumVisits= 48,990,198
iii) PVs= 1,122,841,424
Vs
B) Taking the same VisitDate and obtaining the same statistics from the GA report:
i) Users count = 1,549,757
ii) Number of pageviews = 11,604,449 (Huge difference when compared to A(iii))
In the hive query above, am I using any wrong fields or processing the fields in a wrong way? Just trying to figure out why I have this difference in numbers.
UPDATE 2 (following #Felipe Hoffa 's suggestion):
This is how I am flattening the tables in my Python code before exporting the result to GCS and then to Hadoop cluster:
queryString = 'SELECT * FROM flatten(flatten(flatten(flatten(flatten(flatten([' + TABLE_NAME + '],hits),hits.product),hits.promotion),hits.customVariables), hits.customDimensions), hits.customMetrics)'
I understand what you are saying about flattening causing repeated pageviews and each repetition getting into the final wrong addition.
I tried the same query (from Update1) on Bigquery table instead of my Hive table. The numbers matched with those on the Google Analytics Dashboard.
However, assuming that the Hive table is all I have and it has those repeated fields due to flattening.. BUT Is there still anyway that I can fix my hive query to match the stats from Google Analytics dashboard?
Logically speaking, if the repeated fields came up due to flattening.. can't I reverse the same thing in my Hive table? If you think that I can reverse, do you have any suggestion as to how I can proceed on it?
Thank you so much in advance!
Can you run the same query in BigQuery, instead of on the data exported to Hive?
My guess: "The data is stored in a hive table. I flattened all the nested and repeated fields before exporting." When flattening - are you repeating pageviews several times, with each repetition getting into the final wrong addition?
Note how data can get duplicated when flattening rows:
SELECT col, x FROM (
SELECT "wrong" col, SUM(totals.pageviews) x
FROM (FLATTEN ([google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910], hits))
), (
SELECT "correct" col, SUM(totals.pageviews) x
FROM [google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
)
col x
wrong 2262
correct 249
Update given "update 2" to the question:
Since BigQuery is working correctly, and this is a Hive problem, you should add that tag to get relevant answers.
Nevertheless, this is how I would correctly de-duplicate previously duplicated rows with BigQuery:
SELECT SUM(pv)
FROM (
SELECT visitId, MAX(totals.pageviews) pv
FROM (FLATTEN ([google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910], hits))
GROUP EACH BY 1
)

select recently incerted record from table in oracle 11g

i have oracle 11g
i have tables employee table and employee time data tables.
and my table having id,employee_no,employee_in Time,...
in one day i get with 1,100,17-JUN-14 04.57.19 PM,..., 2,100,17-JUN-14 05.57 PM...etc multiple records with multiple employe ids.
how to get recently get recorded with using employee_no.
i already tried with join of both tables and try to get employee name and employee_in Time
please save my days.
It would really help to know the table structures and relevant columns in each. In addition it helps to know sample data and expected results and what you've tried to date.
Based on statement to " recently get recorded with using employee_no." I take to mean get the most recent employee_in_time for each employee.
Select max(employee_In_Time), employee_no, trunc(employee_In_time) as CalDay
from employee_Time
Group by employee_no, trunc(employee_In_time)
This would return the most recent time entry for each employee, if you need other data from employee table a join should suffice. but without knowing results... not sure what you're after.

Get the number of Rows returned by a OleDbDataReader ASP.NET (VB)

After connecting to a database using DataReader, how can I count the number of rows ?
Thanks.
Data readers are forward only so they don't have the count when first filled. You can do several things to address this:
Run a separate command to get the count OR using NextResult to help instead of a totally separate command).
Loop through the results and count the records
Use a DataSet
Here's an example of #1:
Without NextResult:
http://www.devx.com/vb2themax/Tip/18807
With NextResult (Doesn't return record count but gives you idea of how to use NextResult):
http://bytes.com/topic/asp-net/answers/295793-datareader-nextresults-question
Here's an example of #2:
http://support.microsoft.com/kb/308050
Only by repeatedly calling Read().
A DataReader is a forward-only view of a resultset and cannot get a count.

Resources