I’m a Tableau developer – but been asked to create a viz from and Cube using MDX (which I have no experience of).
The Cube is connected to Tableau, some Sets have been created for Time dimensions - Current Month etc – but totally lost trying to aggregate results so I can move on...
The Data I have is a simple survey with 3 questions. The responder (I responder per Form ID) can give 1 of 4 answers to each question – or ignore it.
2 sets have been created in Tableau to reflect these:
Set 1 Questions: Q1, Q2, Q3
Set 2 Answers: No, Maybe, Probably, Yes (and not answered/#NA)
So far, using ad CASE Statement in Tableau Calculated Members, I’ve assigned a value to each of these answers – No = 0, Maybe = 33, Probably = 67, Yes = 100 or #NA.
I’ve created 2 Calculated Members:
[Count of Answers] – so I can show volume of surveys answered:
IIF([Answer].[SAnswer].currentmember = [Yes], [Measures].[Number Of
Answers], (IIF([Answer].[SAnswer].currentmember = [Probably], [Measures].
[Number Of Answers], (IIF([Answer].[SAnswer].currentmember = [Maybe],
[Measures].[Number Of Answers], (IIF([Answer].[SAnswer].currentmember =
[No], [Measures].[Number Of Answers],0)))))))
And,
[Survery Scores]
CASE
WHEN [Answer].[SAnswer].currentmember = [Yes] THEN 1.00
WHEN [Answer].[SAnswer].currentmember = [Probably] THEN 0.67
WHEN [Answer].[SAnswer].currentmember = [Maybe] THEN 0.33
WHEN [Answer].[SAnswer].currentmember = [No] THEN 0.00
ELSE NULL
END
Where I’m stuck – For each survey form completed, I need the average score:
[Form ID].[001], has 3 questions answered: Q1 = 67%, Q2 = 67%, Q3 = 67% so average is 67%
[Form ID].[002], has 2 questions answered: Q1 = 100%, Q3 = 0% so average is 50%
I’ll need to aggregate these Scored by Country, Region, Job Type, Month hierarchies etc…if I was just using an flat extract I’d use a Nested Include/Fixed LOD…so if the 2 forms above were in the same [June].[USA].[Cleaning] the score would be average of 58.5%.
I'd appreciate a steer on what I need to do to create an aggregated score measure averaging the average score-per-form at any level. Many thanks in advance.
Your problem is related more to your Cube design then MDX. The average method that you explained above indicates that the grain of your fact is your form . I would suggest that you edit the design of your fact, by grouping on the fact on formid. Now at what ever data point you query the data the result will be fine.
Related
I am working on a task in order to learn PostgreSQL, and got stuck on a problem.
Given the two tables: a star-table and a planet-table. The star-table contains star systems, and the planet-table contains planets that are located within the star systems. In other words the planet-table references the star-table with the foreign key star.
My question is: How do you query for a planet name that is contained in a solar system with two planets with a mass greater than 10 standard masses, where the star has a distance less than 50 parsecs away from our sun? (The standard mass measurement in this specific task is a scale of Jupiter masses referenced as a whole number).
the tables look like this:
My best previous attempt goes likes this, and return 79 rows.
SELECT p.name, s.name FROM planet AS p
INNER JOIN star AS s
ON (s.name = p.star)
WHERE s.distance < 50 AND p.mass > 10; -- I don't know how to check for two planets with a mass greater than 10
The correct answer should return 4 rows.
All help is appreciated and much welcomed
Your query will do, but since you only want to query for the star system, the following may be closer to what you want:
SELECT s.name
FROM star AS s
WHERE s.distance < 50
AND EXISTS (SELECT 1 FROM planet AS p
WHERE s.name = p.star
AND p.mass > 10);
I want to compare how different campaigns are progressing based on number of days into the campaign rather than by date (see day1, day2, etc... on the x-axis below).
Here is my DAX code, but I can't get it to work. Any help would be much appreciated...
**Normalised Campaign Metrics =
VAR DateReached = CALCULATE(MIN(Days[Day]),db[PAYMENT_DATE]<> BLANK(), KEEPFILTERS(db[PRODUCT_CODE SWITCH]))
VAR MaxDate = CALCULATE(MAX(db[PAYMENT_DATE]),KEEPFILTERS(db[PRODUCT_CODE SWITCH]))
VAR DayNo = SELECTEDVALUE(Days[Day])
RETURN CALCULATE(count(db[PAYMENT_DATE]),
FILTER(ALL(db[PAYMENT_DATE]),
DateReached+DayNo && DateReached+DayNo<=MaxDate))**
Many thanks!
enter image description here
I would recommend solving this through manipulating your actual data rather than a complex DAX measure. If you are familiar with star schema modelling, I would solve this problem by adding a new column to your fact table that calculates how many days from the start date the payment occurred and then connect this column to a new "Days Passed" dimension that is simply a list of numbers from 1 to however many days you need. Then, you can use this new dimension as the source data for your x axis and use a standard payment amount measure for your y axis.
I recommend to create a dimension table as the relative basis to comparison with inactive relationship. Here is a video about it:
https://youtu.be/knXFVf2ipro
i'm totally new to Tableau but that is what I could potentially use at the workplace, so asking this question to decide if its worth it.
I've a monthly values dataset and I'd like the tool (Tableau) to generate a report to point out anomalies - the ones i have in mind right now are:
1) same data value for x months in a row
2) data value is 0
3) 5 parameters been reported last 3 months and all of sudden only 4 are reported
Is this possible in Tableau?
You can certainly do this. The below is a general example for doing anomaly detection (one standard deviation outside of mean) but you can modify the calc to fit your criteria. If you place your date field in the column position and your metric, lets say Sales, in the row position you can then create this calculated field to label the anomalies.
IF SUM([Sales]) < (WINDOW_AVG(SUM([Sales])) – WINDOW_STDEV(SUM([Sales]))) THEN “Bad
Anomaly”
ELSEIF SUM([Sales]) > (WINDOW_AVG(SUM([Sales])) + WINDOW_STDEV(SUM([Sales]))) THEN
“Good Anomaly”
ELSE “Expected”
END
You can then place the new field on your color mark to highlight each of the results.
I have the following chart, which uses Quick Table calculation to count the percentage of the values across the group Category for each month.
What I want is to count the percentage of the monthly running total of the values across the group Category for each month. I can create the quick calculation for monthly running total, separately, but I can't seem to combine it with this below because one requires quick calculation across the table and another across the group. Can anyone advise if this is doable?
The workbook attached here, with the problem above in the second tab.
Edit: Let me give example what I meant here:
April: A = 1000, B=500, C= 200, D=300 -> total is 2000
percentage in April in chart is A = 1000/2000 = 50%, B = 25%, C = 10%, D = 15%, total = 100%
May: A=2000, B=2000, C=1800, D=200 ->
cumulative April+May A=3000, B=2500, C=2000, D=500 -> total is 8000
percentage in May in chart is A=3000/8000 = 37.5%, B = 31.25%, C = 25%, D = 6.25%, total = 100%
I got an answer elsewhere and thought I should update here. The solution was to use a secondary table calculation. Basically, after putting SUM(Value) pill in Row:
right click on it to select Add Table Calculation
set as primary calculation the Running Total Sum of Table (Across)
check the box to Perform a secondary calculation on the result
set as secondary calculation the Percent of Total of Table (Down)
See below screenshot of the setting.
Are you looking for ways to calculate the sum of the running total across the category? it is not clear when you say to count the percentage? However if you are looking for sum of percentage running total across your category... you can edit your calculation and set the calculation type as running total, the summarize value ( you can choose, sum , average, min,...max) and the running along option choose category.
I am using Crystal 9 and have created a report showing calls logged by users, time taken to close the call, Solved with (allocated a value to the latter field depending on time taken eg. 1-59 mins = < 1 hr = 1), 60-239 mins = < 4 = 4. I have then grouped the results by users and got totals for each of the Solved values
Solved1 = solved in less than 1 hour
eg group total shows (when record data hidden)
User1 (Total Calls= 74) (Solved1 = 42) (Percentage1 = 56.76)
User2 (Total Calls= 17) (Solved1 = 2) (Percentage1 = 11.76)
Total Calls and Solved1 are obtained using Running Total Fields.
Percentages are Formula fields and calculated as follows:
Percentage1 = Solved1/Total Calls * 100
My problem is that I need to graph the percentage values for each user for each Solved value eg. 56.76 and 11.76 on one chart. This would be easy except that Crystal doesn't let me select this field in the chart option because it's calculated from two Running Totals.
Since some formulas are accepted by the Chart expert and running totals are also accepted, is there a way I can calculate the percentage which it would find acceptable? Or can I put the total and Solved value in the chart and have the chart calculate the percentage somehow? I was looking at using count and I can get the count to count all the records for a single person but not where say the value in a specific field = '1'
eg count (call_id, )/count (call_id, closedby) * 100
Does anyone know how I can write that fomula or any other way of graphing a percentage?
You can do this using Crystal formulas.
Set up a formula for Solved1 - something like
if {myTable.timeTaken} < 60 then 1 else 0
Next, set up a formula for Percentage1 - something like:
100*sum(#Solved1,{myTable.closedBy}) / count({myTable.call_id},{myTable.closedBy})
Drag and drop the formula for Percentage1 onto the report layout, then you should be able to add it from Report Fields onto your graph in the Data tab of the Chart Expert. (You may then want to remove the Percentage1 formula item from the report layout.)
I ran into a similar issue trying to graph On Time Delivery percentages.
I have three percentages to display: On Time, 1-3 days late, and over 3 days late.
I was in need of displaying zero percents as well, i.e. when there were no records that were "1-3 days late" I still needed to show 0% as one of my bars. The above did not address that. I ended using this resolution with a twist.
I created 4 formulas:
one to return 1 if the record was on time else 0
one for the 1-3 days,
one for the over 3 records.
one for each record returning a value of 1.
With that I was able to create my percentage fields using the Sum of one of the first 3 formulas divided by the sum of the "1" formula. Crystal would not work if I used the Count(...) function on a key field. It only worked when using the Sum(...) function in my percentage formulas.