I have a calculated field a/b which makes sense at week level, where a is last of period metric and b is sum of the period metric. I need to find avg(a/b) for the weeks that fall under a month and not end_of_month(a)/sum(b) for the month. I made my a/b metric with regular aggregate as calculated and then monthly average metric with regular aggregate as average, but it doesn't work. The report is a crosstab report. How can I solve this?
Edit: a is end on hand inventory, b is sales, a/b is weeks of supply. Both a and b spread along product/location/time dimensions. For a, I've set its regular aggregate for time as last.
Your form of expression gives me error, so, I tried average((total([a] for [week]))/(total([b] for [week]))) which is error-free but doesn't give correct result. I used total[a] because it still has to sum along other dimensions except time. Any ideas?
I was also trying an alternative way- get the individual weeks of supply and then derive a new metric as (first week wos + ...+fifth week wos)/5. But I get a warning when I try to put a case statement as "Relational query objects are being used in conjunction with Dimensionally-modeled relational objects", and the metric give garbage value. How can I apply case involving relational item in query items of measure dimension?
You have to be more clearer on what you are trying to achieve.
Also, the header says framework manager, while you are talking about report.
My best guess is you need to use the for expression in your aggregate the values:
avg((max([a] for [week]))/(sum([b] for [week])))
You might need to use other (more sophisticated) summary function
for more details about the FOR and AT look here:
Using the AT and FOR Options with Relational Summary Functions
Related
I'm having difficulty replicating the following Excel calculation in power BI
=IFERROR(AVERAGEIFS(Data!$I:$I,Data!$A:$A,Tables!$C$2,Data!$B:$B,Tables!$E$2,Data!$E:$E,Tables!$B5), "N/A")
I am trying to calculate an average on 3 values, area, period and metric. In power bi using the quick measure it returns either the count of the metric title or the average of the metric, with an additional row for the values that are marked as n/a.
Count of Raw_Score average per metric_ref =
AVERAGEX(
KEEPFILTERS(VALUES('Data'[metric_ref])),
CALCULATE(COUNTA('Data'[Raw_Score]))
)
files / images here
maybe I understood the question wrong, so feel free to correct me, but you are simply trying to calculate an average for different groups, is that so?
First, when working with PowerBI do yourself a favor and forget how Excel works, your life ll be much easier.
Now for the solution.
The trouble is, that your score metric is not a correct data type for average calculation. In Edit Queries, change data type to number (prior step of replacing "N/A" to "" might be required)
(optional step) I would recommend fixing data type of all relevant columns.
With data in correct format, you simply create visualization and slice it with grouping label. Something like this:
Notice the small arrow near the Value-theme_ref field (in your case you should probably substitute it with Raw_Score columns). You simply change the calculation from Sum to Average, which should do the trick.
Once again, I apologize if I misunderstood the question. Feel free to specify.
I am averaging a number, grouped by week inside of Google Data Studio, and i am averaging the same numbers grouped by week inside of Big query however the output is slightly different.
Overall Score
AVG(table.score) OVER (PARTITION BY Weeknum) as OverallScore
The datasource is a list of scores, along with a date. I am averaging this inside DS using the aggregate function within the metric, and using the Time dimension ISO Year Week.
The purpose of this is to have one set of numbers hard coded, whilst the other line is used to filter to different departments, keeping the original "overall" score present to be used as a benchmark.
Exporting my table into excel, i can average it filtered by week 3 (See below) and i it returns 19.59 as well. Meaning, the avg aggregate function inside Datastudio is the same as excel. Also, i can query the table using the below, which rules out an averaging difference inside bigquery. However when i place overall score into the graph below i get slightly different numbers for the overall score..
SELECT avg(overallscore) FROM `dbo.table` where weeknum = '2018 3'
Output = 19.59
Does anyone have an idea what may be causing this?
When you open the report, you should be able to see the query it runs in your query history in Big Query. Check that it's using the same formula as sometimes it uses approximate aggregates.
I have a question for statistical method which i cant find in my textbook. I want to compare data of two groups. For example, both group have data of day 0, but one group have data of day 2, and another day 6. How can I analyse the outcome with the data and the date? i.e. I want to show that the if data taken on day XX are YY, it has an impact on the outcome.
Thanks in advance.
I'd use a repeated measures ANOVA in this case. However, since you don't have a complete dataset, day X and Y would be just operationalized as the endpoint of your dependent variable. If you'd have measures of all days I'd include.all of them in the analysis in order to fully compare the two timelines. You could then also compare the days of interest directly by using post-hoc tests (e.g. Bonferroni)
I am working on a data set and I need to calculate the daily revenue of fake AirBnb listings using nested IF statements. This is for a bootcamp I am attending, and I am stuck.
My instructions are as follows:
Estimate revenue per listing
Assume each booking always has 2 guests, unless the listing accommodates only one;
The booking is always for the minimum number of days allowed;
Only half of the bookings generate a review;
The extra person charge is per night (column name ‘extra_people’)
○ Format: have a column that calculates daily revenue (account for number of guests accommodated, number of guests included in the price, extra charge for additional people - using nested IF statements); another column would then calculates revenue per booking; finally, multiply that by the number of total stays the listings has had.
Using the data in my dataset, I am attempting to fill out column AA. So far this is what I have for my formula,
However, I get an error. I know the first part of this formula would work for the scenario in row 4. However, I need to make sure that the formula takes into account scenarios where the "guests included" is less than the "accommodates", because I must assume that each booking always has two guests except for when the listing only accommodates one person.
How should this formula be written? Can I not create equations within nested if formulas if it includes adding, subtracting, dividing, or multiplying columns together?
To clarify the previous response a bit more, the structuring of IFstatements is important. Keep in mind the structure of the function: =IF(logical test, value if true, value if false). So, the second IF function (the first nested) needs to be placed where the first "value if false" comes in - each additional IF needs to be within the previous IF function. Using your example, the corrected form would be =IF(W4=Q4,V4,IF(W4<Q4,Q4*V4...)). I'm not sure what the "+X4" is supposed to be adding to, but this hopefully makes the structure clearer for you to work with. Good luck!
Is it possible to calculate a percentage change in a Cognos Report?
Currently, I have a crosstab that has years as the columns and widgets in the rows with a calculation of total revenue. I am looking to calculate the annual % increase. New to Cognos, but I could accomplish this using other tools.
Any help will be very much appreciated.
Sorry for the late answer to your question but perhaps it will help others who see it.
It's kind of annoying, but it can be done. If you have one Query which uses an input parameter to select the year, perhaps it is a filter that says [Year] = ?YearPrompt?, then you can make a second Query which uses the filter [Year] = ?YearPrompt? - 1. Then, you can join these two queries, and the third query (made by joining the first two) will have both this year's revenue, and last year's revenue, available to it for a calculation, such as what the percent change is.
You need to create a query calculation item as one of the columns and in it you take Year2 - Year1(You can choose the exact columns you already have in the report using the Data Items tab when you are making the query calc) Also make sure you make this query calc a % in its format.