I want to calculate tasks per day(no of tasks/no of unique users) in my dashboard.
I used the distinct count to get the unique no of employees. When I put the measure in pivot, day wise calculation is okay but at the end in MTD it is not added the day wise unique no of emp.
Tasks per day:=divide(sum(fdata[resolved]),distinctcount(fdata[sap id]))
I expect the output like second table.
Model
Date ID Resolved
12-05-2019 a 1
12-05-2019 a 1
12-05-2019 b 1
13-05-2019 a 1
13-05-2019 b 1
13-05-2019 c 1
Expected Result
Date No of emp Resolved Task Per Day
12-05-2019 2 3 1.5
13-05-2019 3 3 1
Grand Total **5** 6 1.2
This will do the trick:
Tasks per day:=
IF(
ISFILTERED( fdata[date] )
, DISTINCTCOUNT( fdata[sap id] )
, COUNTROWS(
GROUPBY(
fdata
, fdata[date]
, fdata[sap id]
)
)
)
Related
I want to implement a running distinct count with Amazon Quicksight. Here's an example of what that would look like:
Date
ID
Amount
Running Distinct Count
1/1/1900
a
1
1
1/2/1900
a
3
1
1/2/1900
b
6
2
1/4/1900
a
3
2
1/8/1900
c
9
3
1/22/1900
d
2
4
I've tried runningSum(distinct_count, [Date ASC]), but this returns a sum of the distinct counts for each aggregated date field.
Can this be implemented in QuickSight?
You can use this workaround to get the same functionality as runningDistinctCount() as follows:
runningSum(
distinct_count(
ifelse(
datetime=minOver({Date}, [{ID}], PRE_AGG),
{ID},
NULL
)),
[{Date} ASC],
[]
)
This would give you the runningDistinctCount of ID's over the Date field. It achieves it by considering just the first time the ID appears in the dataset, counting these and finally doing a runningSum on these counts.
I am using this:
'Total = SUMX(
FILTER(
Table1,
Table1[Client] = EARLIER( Table1[Client] )
),
Table1[Sales])'
In the table I have many results that are duplicated in the column created here, I still have a use for the value but I want a way to possibly insert 'nulls' or blanks in instances where 'Client/Sales' pairs (across the rows) are already accounted for. Is there a way to take both columns and when an instance is 'repeated' to insert a blank?
This is what things look like now...
Client
Sales
Total
1hk4
4
8
1hk4
2
8
4f33
1
3
5t23
3
5
4f33
1
3
1hk4
2
8
4f33
1
3
5t23
2
5
This is what I'm trying to go for:
Client
Sales
Total
1hk4
4
8
1hk4
2
4f33
1
3
5t23
3
5
4f33
1
1hk4
2
4f33
1
5t23
2
The reason I'm trying for this is because in the report I am unable to turn off summarize and the data doesn't relay well. Ideally I want to be able to see the unique result by client.
Lets say you can add a column to your table with a unique index for each row:
Then you can add a calculated column like this:
Total =
var currnetIndex = [Index]
var currentClient = [Client]
var minIndex =
CALCULATE(
MIN('Data'[Index]),
FILTER(
ALL('Data'),
'Data'[Client] = currentClient
)
)
return
IF(
currnetIndex = minIndex,
CALCULATE(
SUM('Data'[Sales]),
FILTER(
ALL(Data),
'Data'[Client] = currentClient
)
),
BLANK()
)
Which will give you a table looking like this:
This solution works if the index is unique only to the user as well.
My tables are as below
MS_ISM_ISSUE
ISSUE_ID ISSUE_DUE_DATE ISSUE_SOURCE_TYPE
I1 25-11-2018 1
I2 25-12-2018 1
I3 27-03-2019 2
MS_ISM_SOURCE_SETUP
SOURCE_ID MODULE_NAME
1 IT-Compliance
2 Risk Assessment
I have written following query.
with rs as
(select
count(ISSUE_ID) as ISSUE_COUNT, src.MODULE_NAME,
case
when ISSUE_DUE_DATE<sysdate then 'Overdue'
when ISSUE_DUE_DATE between sysdate and sysdate + 90 then 'Within 3 months'
when ISSUE_DUE_DATE>sysdate+90 then 'Beyond 90 days'
end as date_range
from MS_ISM_ISSUE issue, MS_ISM_SOURCE_SETUP src
where issue.Issue_source_type = src.source_id
group by src.MODULE_NAME, case
when ISSUE_DUE_DATE<sysdate then 'Overdue'
when ISSUE_DUE_DATE between sysdate and sysdate + 90 then 'Within 3 months'
when ISSUE_DUE_DATE>sysdate+90 then 'Beyond 90 days'
end)
select ISSUE_COUNT,MODULE_NAME, DATE_RANGE,
(select count(ISSUE_COUNT) from rs where rs.MODULE_NAME=MODULE_NAME) as total from rs;
The output of the code is as below.
ISSUE_COUNT MODULE_NAME DATE_RANGE Total
1 IT-Compliance Overdue 3
1 IT-Compliance Within 3 months 3
1 Risk Assessment Beyond 90 days 3
The result is correct till 3rd column. In 4th column what I want is, total of Issue count for given module name. Hence in above case Total column will have value as 2 for first and second row (since there are 2 Issues for IT-Compliance) and value 1 for the third row (since one issue is present for Risk Assessment).
Essentially, I want to achieve is to replace current row's MODULE_NAME in last where clause. How do I achieve this using query?
OK, this condition
where rs.MODULE_NAME=MODULE_NAME
is essentially the same as if you wrote
where MODULE_NAME = MODULE_NAME
which is simply always true (if there are no nulls in module_name).
Try using different table alias for inner query and outer query, e.g.
select count(ISSUE_COUNT) from rs rs2 where rs2.MODULE_NAME=rs.MODULE_NAME
You can also try to use analytic function here, something like
select ISSUE_COUNT,
MODULE_NAME,
DATE_RANGE,
COUNT(ISSUE_COUNT) OVER (PARTITION BY RS.MODULE_NAME) AS TOTAL
from rs
instead of your subquery
I have data as follows
EmployeeID Cycle Val Group
1 1 6 A
2 1 5 A
My desired result is as follows:
EmployeeID Cycle GroupVal
1 1 5.5
2 1 5.5
I have written 2 Measures as follows:
Emp_AVG: CALCULATE(AVERAGE(EmployeeFeedback, EmployeeFeedback[Val] > 0)
Group_AVG: CALCULATE(AVERAGEX(EmployeeFeedback[Emp_AVG],EmployeeFeedback[Emp_AVG] >0)
My thought process is that the Group_AVG is averaging the avg of all employees PER GROUP however since i need the results for a SPECIFIC employee, as soon as i introduce that column, it starts slicing by the Employee and the Group avg becomes inaccurate. I guess i need to generate Group Avgs before i do any employee filtering..how?
I am running a DAX query as follows:
EVALUATE SUMMARIZECOLUMNS(
EmployeeFeedback[EmployeeID],
EmployeeFeedback[Cycle],
"Group Val", [Group_AVG]
)
I need the EmployeeID to filter it down to an employee but because of EmployeeID, the Group AVG gets screwed. Without EmployeeID, Group AVG is correct but then there is no way to filter it for a specific Employee!
Thanks!
You could try to provide the ALLEXCEPT() argument to the CALCULATE function.
Btw, I believe there's an error in your Emp_AVG measure.
Try this:
Employee Average
Emp_AVG =
CALCULATE(
AVERAGE(EmployeeFeedback[Val]),
EmployeeFeedback[Val] > 0)
Group Average
Grp_Avg =
CALCULATE(EmployeeFeedback[Emp_AVG],
ALLEXCEPT(EmployeeFeedback,EmployeeFeedback[Group]))
Result:
I have someting like this
id day descrition
1 1 hi
1 1 today
1 1 is a beautifull
1 1 day
1 2 exemplo
1 2 for
1 2 this case
I need to do a funtion that for each day concatenate the descrtiomn colunm and return the result like this
id day descrition
1 1 hi today is a beautifull thay
1 2 exemplo for this case
Anny ideia about how can i do this usisng a loop in a function in oracle
You need a way of determining which order the values should be aggregated. The snippet below will rely on the implicit order in which Oracle reads the rows from the datafiles - if you have row movement enabled then you may get inconsistent results as the rows can be read in different orders as they are relocated in the underlying datafiles.
SELECT LISTAGG( description, ' ' ) WITHIN GROUP ( ORDER BY ROWNUM ) AS description
FROM your_table
GROUP BY id, day
It would be better to have another column that stores the order within each day.