Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, everybody.
I worked with OBIEE for a few years, and I'm starting with Power BI.
I'm currently struggling with its formula sintax on front-end, and I kindly need some help with one quite simple calculation, please:
For one particular Dashboard page, I only have one page filter, which is "Week" ("Week 01", "Week 02", "Week 03", etc.)
I have a metric "Order Value", and I actually need is to calculate the Average Sum of the Order Value for the current week and the 3 previous ones.
I mean, if I choose "Week 31" on the page filter, the measure shoud calculate the Average Sum from Weeks 31, 30, 29 and 28.
Just as a reference, in OBIEE I would define a presentation variable for the Week Filter, and I'd create a Measure that would consider the selected week through the variable on the formula and summarize the Order Value for current week + (current week-1) + (current week -2), etc, and then apply AVERAGE on it, but that doesn't seem like a workaround applicable for Power BI.
Thank you very much in advance.
I really appreciate your help.
Looking forward for your reply
Solved! Go to Solution.
Hello, Daniel.
I wasn't aware of the functions "ALL" and "SELECTEDVALUE".
It worked out just fine.
Thank you very much!
You're a life saver.
Best regards.
Hi @Anonymous,
Based on my test, you could refer to below steps:
Sample data:
Create an Index column:
Index = RANKX('Table1',FIRSTNONBLANK('Table1'[Week],'Table1'[Week]),,ASC,Dense)
Create a measure:
Measure = CALCULATE(AVERAGE(Table1[Value]),FILTER(ALL('Table1'),'Table1'[Index]>=SELECTEDVALUE(Table1[Index])-3&&'Table1'[Index]<=SELECTEDVALUE(Table1[Index])))
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He
Hello, Daniel.
I wasn't aware of the functions "ALL" and "SELECTEDVALUE".
It worked out just fine.
Thank you very much!
You're a life saver.
Best regards.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
95 | |
80 | |
67 | |
62 |
User | Count |
---|---|
147 | |
109 | |
107 | |
85 | |
63 |