Duplicated dates POWER BI - database

I am new in Power BI, and I am struggling with how to resolve an issue.
I made measures to calculate my total feedback. The feedback column can be POS, NEG, and Neutral. The overall sentiment I calculated by taking pos feedback and dividing by all feedback.
totalFeedback = CALCULATE(COUNTROWS('feeback'),'feedback'[sentiment] = "POS")/ COUNTA('feedback'[sentiment])
Now when I want to calculate the difference between two months. Example today's, and last month I get an error saying duplicates dates.
difference = CALCULATE([totalFeedback], DATEADD(FILTER('comment'[created_at], 'comment'[created_at] < TODAY()),-1,MONTH)
I get an error saying: A date column containing duplicate dates was specified in the call to function 'DATEADD'. This is not supported
What I did was I created a DATE TABLE and made a relationship with the comment[created_at].
DimDate= CALENDARAUTO(12).
Now, I don't get the error anymore, but non of the data is shown when adding the measure in the table.
I need advice, thanks

Related

How do I calculate Turnaround rate (%) in SSRS?

I am creating a SSRS report and one of the requirements of the report is to display ‘Turnaround Rate’ which is supposed to contain values in percentage.
Some of the columns from my dataset are like:-
DateReceived
DateCompleted
CompleteTurnaround
TurnaroundVolume
MaximumTurnaroundDays
TurnaroundInMonth
TurnaroundInStandard
I’ve done an extensive research on the topic and haven’t found a solution yet. Also absolutely lost here and would really appreciate any help with this problem.
Thanks.
I think a Turnaround Rate would be based upon records that were completed within the Standard amount of time as indicated in the TurnaroundInStandard column.
Assuming there's one record per and your grouping them, it should be the records that were complete within the standard amount of time (TurnaroundInStandard = 1 or Y, depending on the field) divided by the number of total number of ones that are complete (CompleteTurnaround = 1 or Y). If so, then your expression would be:
=SUM(IIF(Fields!CompleteTurnaround.Value = "Y", 1, 0))
/
SUM(IIF(Fields!TurnaroundInStandard.Value = "Y", 1, 0))

MS Excel 2010 Count unique values with multiple criteria and EDATE

I am trying to get a count of all Unique values listed in Col A, by state and within a date range, for example all records up to the end of April 2018.
I am able to get the count of Unique values by state (result is 2) with the below formula:
{=SUMPRODUCT(1*(FREQUENCY(IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0)),ROW($A$2:$A$14)-ROW($A$2))>0))}
but I am unable to get the IF function to work with EDATE. I tried the following but I'm getting 0 as the result. The result should be 1.
{=SUMPRODUCT(1*(FREQUENCY(IF(D2:D14="<"&EDATE(G1,1),IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0))),ROW($A$2:$A$14)-ROW($A$2))>0))}
I am unable to use Pivot as I need to include date range filter. Could someone please look at my code and tell me what I'm doing wrong? I am using CSE with my formulas. Thankyou!
I managed to work it out. EDATE wasn't working so I entered the Month date in cell:G1 then referenced it in the IF formula using "<=" eg: IF(D2:D14<=G1).
Whole array formula is:
`{=SUMPRODUCT(1*(FREQUENCY(IF(D2:D14<=G1,IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0))),ROW($A$2:$A$14)-ROW($A$2))>0))}
I now receive the correct count of 1, though I have to ensure I have entered the last day of the Month in G1. State is referenced in F10 and count of unique values is in Column A.
My full data set is sourced from multiple documents over 5000 rows each and growing daily so my workbook is quite slow to calculate over 1000 array formulas... but it works!
If anyone knows of a faster (possibly non-array) formula, I would appreciate the advice! Thanks!

Google Data Studio date aggregation - average number of daily users over time

This should be simple so I think I am missing it. I have a simple line chart that shows Users per day over 28 days (X axis is date, Y axis is number of users). I am using hard-coded 28 days here just to get it to work.
I want to add a scorecard for average daily users over the 28 day time frame. I tried to use a calculated field AVG(Users) but this shows an error for re-aggregating an aggregated value. Then I tried Users/28, but the result oddly is the value of Users for today. The division seems to be completely ignored.
What is the best way to show average number of daily users over a time frame? Average daily users over 10 days, 20 day, etc.
Try to create a new metric that counts the dates eg
Count of Date = COUNT(Date) or
Count of Date = COUNT_DISTINCT(Date) in case you have duplicated dates
Then create another metric for average users
Users AVG = (Users / Count of Date)
The average depends on the timeframe you have selected. If you are selecting the last 28 days the average is for those 28 days (dates), if you filter 20 days the average is for those 20 days etc.
Hope that helps.
I have been able to do this in an extremely crude and ugly manner using Google Sheets as a means to do the calculation and serve as a data source for Data studio.
This may be useful for other people trying to do the same thing. This assumes you know how to work with GA data in Sheets and are starting with a Report Configuration. There must be a better way.
Example for Average Number of Daily Users over the last 7 days:
Edit the Report Configuration fields:
Report Name: create one report per day, in this case 7 reports. Name them (for example) Users-1 through Users-7. These are your Row 2 values. You'll have 7 columns, with the first report name in column B.
Start Date and End Date: use TODAY()-X where X is the number of days previous to define the start and end dates for each report. Each report will contain the user count for one day. Report Users-1 will use TODAY()-1 for start and end, etc.
Metrics: enter the metrics e.g. ga:users and ga:new users
Create the reports
Use 'Run reports' to have the result sheets created and populated.
Create a sheet for an interim data set you will use as the basis for the average calculation. The first column is date, the remaining columns are for the metrics, in this case Users and New Users.
Populate the interim data set with the dates and values. You will reference the Report Configuration to get the dates, and you will pull the metrics from each of the individual reports. At this stage you have a sheet with date in first columns and values in subsequent columns with a row for each day's values. Be sure to use a header.
Finally, create a sheet that averages the values in the interim data set. This sheet will have a column for each metric, with one value per column. The one value is calculated from the series in the interim data set, for example =AVG(interim_sheet_reference:range) or any other calculation you'd like to do.
At last, you can use Data Studio to connect to this data source and use the values. For counts of users such as this example, you would use Sum as the aggregation field type when you are creating the data source.
It's super ugly but it works.

Tableau – Using Nested Aggregations to Establish a Weekday/Hour Baseline

Background Information: We have an incident time tracker that tracks how long each user spends with a representative before the issue can be closed. We want to determine the average volume of incidents that are being handled for each hour. To say this in another way: We want to get an hourly baseline for each day of the week that will show us the average total call length within the specific time period. Eg: We want to average the total length of every call on Monday from 9AM-10AM for all the weeks in the database, and the same for other hourly intervals.
The simplest way to think of this is that I want AVG(SUM) for the specific time periods, but Tableau does not allow me to do this.
Tableau Output:
This is the desired, target visualization that I am looking for from Tableau.
SQL Query:
I have written a SQL query that returns the answer:
We are looking at two columns: start_time (time stamp) and interval_seconds(float)
In the inner query I use the hour_start function which truncates the date/time value to the hour start, so I can group by the hour and day of the week in the outer query.
SQL Results:
Question:
Is there a way to solve this problem ENTIRELY in Tableau that would get me the result that I am looking for without having to write any SQL code?
Files Stored on Drive
CSV File:
https://drive.google.com/open?id=0B4nMLxIVTDc7NEtqWlpHdVozRXc
Tableau Worksheet:
https://drive.google.com/open?id=0B4nMLxIVTDc7M3A4Q0JxbGdlTE0
You can use Level of Detail expressions to compute the SUM(interval_seconds) at the hour level and then use AVG to calculate the number you are looking for.
I created a couple of calculations:
hour which is defined as: DATETRUNC('hour',[start_time])
this should be equivalent to your hour_start(start_time).
and interval_hours which is defined as {FIXED [hour] : SUM([interval_seconds])/3600 }
This calculates the aggregate for each start_time truncated to the hour.
After this, you simply calculate AVG(interval_hours) and use it in your view.
I put a workbook in dropbox: https://www.dropbox.com/s/3hfvz8w529g9f46/Interval%20Time%20Baseline.twbx?dl=0
Although the chart looks similar to yours, the numbers I came up with are somewhat different from the "SQL Results" you show. Was the data you provided slightly different?

Efficient Excel formula for returning multiple matches from a large number of rows

I'm stumped by a major issue. I have a data set consisting of about 16000 rows (could be more in future). This list is basically a price list containing products and their corresponding installation fees. Now the products are classified by the following hierarchy: City -> Category -> Rating/Type. Before I was using named ranges to refer to each set by concatenating City & Category & Rating (_XYZ_SPC_9.5). This resulted in about 1500 named ranges which inflated the size of the Excel file. So I decided to calculate the products on-the-fly using inputs from the user. I have tried array formulas and simple formulas but they take some time to calculate (16000 rows!!) which is not acceptable from a usability perspective; our sales people are very particular about how much time they have to spend on the tool.
I have uploaded a sample file at:
Price List Sample
Formulas that I have used so far are:
=IFERROR(INDEX($H$6:$H$15000, SMALL(INDEX(($AE$9=$R$6:$R$15000)*(MATCH(ROW($R$6:$R$15000), ROW($R$6:$R$15000)))+($AE$9<>$R$6:$R$15000)*15000, 0, 0), AC3)),"Not Available")
{=IFERROR(INDEX(ref_PRICE_LIST!$H$6:$H$16074,MATCH(INDEX(ref_PRICE_LIST!$H$6:$H$16074,(SMALL(IF(IF(RIGHT($AE$3,3)="All",ref_PRICE_LIST!$Z$6:$Z$16074,ref_PRICE_LIST!$R$6:$R$16074)=$AE$3,ROW(ref_PRICE_LIST!$H$6:$H$16074)-ROW(ref_PRICE_LIST!$H$6)+1),$AC3))),ref_PRICE_LIST!$H$6:$H$16074,0),1),"Not Available")}
I would really appreciate if someone can help me out.
Thank you so much!
I think the best way to speed this up is to split the formula into a helper column K and a reult column L
Helper Column (copy down for all 16,000 data rows)
=IF($D:$D=$O$2,ROW(),"")
Result column (starting at L2, copy down as many as you need)
=IFERROR(INDEX($F:$F,SMALL($K:$K,ROW()-1)),"Not available")
I've tested this with about 150,000 rows and it updates in < 1s

Resources