The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello all.
I am fairly new to Power BI, but I have managed some basic things already.
My problem at the moment is as follows:
I am using the following tables:
date table (date, iso_week, year, month, month_name)
orders (order_number, order_date, number_produced, SAP_number)
repairs (order_number, SAP_number, repair_id, repair_date and some more columns)
and a table with dax calculations:
dax (repairs[distinctcount with repair_id], produced_items[sum of number_produced], repair_quote[repairs/produced_items])
So far this works, I can display the number of produced items per iso_week and also show the RQ for each of these weeks, and I can also filter for different SAP numbers and years. Basic, I know.
Now I want to calculate a rolling 6 week average of the calculated RQ value - and nothing I've found online so far works.
Because I have my own date table I cannot use the quick measure.
I don't know where to look.
What I have so far is this:
Produced 6W =
CALCULATE(
AVERAGE('DAX'[RQ]),
DATESINPERIOD(Dim_Datum[Date],LASTDATE(Dim_Datum[Date]),-42, DAY)
)
But it does not show me any values for the weeks of any year.
Help would be much appreciated!
I've just watched another tutorial about creating rolling average measures.
Can it be the reason mine is not working is that my measure "RQ" has somehow no connection to a date so I can't use the average functions with dates because I am calculating the RQ value for each individual week?
Maybe I should step back and ask: how should I arrange my tables and measures so I can calculate a RQ for each order and then show for each week or month the number of orders, the RQ and the 6wAVRG RQ?
Quick update:
I changed the formula as follows:
Produced 6W =
CALCULATE(
AVERAGEX('DAX','DAX'[RQ]),
DATESINPERIOD(Dim_Datum[Date],LASTDATE(Dim_Datum[Date]),-42, DAY)
)
This somehow gives me a calculated value of 7,69% - but its the same for all weeks.
Hi @stw - can you try below measure for week
Rolling_6W_Avg_RQ =
CALCULATE(
AVERAGE('DAX'[Repair_Quote]),
DATESINPERIOD(
Dim_Datum[Date],
LASTDATE(Dim_Datum[Date]),
-6,
WEEK
)
)
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Unfortunately, WEEK is not a valid argument. Only DAY MONTH YEAR QUARTER are available.
Also, changing the function from
AVERAGEX('DAX','DAX'[RQ])
to
AVERAGE(DAX[RQ])
gives me an error saying
"column RQ was not found in table dax or cannot be used here"
Maybe there is a problem with the date table and/or the connections between the tables and the calculated measure?