Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!View all the Fabric Data Days sessions on demand. View schedule
I have really problem about this:( I hope u can help me about this topic.
Thank u before your answers.
Today=X
I want to solve this porblem with dax.
My data occured
Sales date, Amount and Product type. Each data correleated with each other.
Aim: Weekly moving average of total weekly sales by day, compared to the total of last 4 week sales
X to X-6 total sales amount / (X-7 to X-34)
Solved! Go to Solution.
so you don't want to compare the last seven days to the 28 days before that, but rather to their average. In that case just multiply by 4.
measure =
var today=max([date])
var lastseven = calculate(sum([Sales]),[date]>today-7)
var lastthirtyfive = calculate(sum([Sales]),[date]>today-35)
return divide (4*lastseven,lastthirtyfive-lastseven)
I also see that you have created all separate measures. Please don't do that. The above code has to go into the definition of your single measure. The variables are part of the measure definition.
Use variables to break the problem down
measure =
var today=max([date])
var lastseven = calculate(sum([Sales]),[date]>today-7)
var lastthirtyfive = calculate(sum([Sales]),[date]>today-35)
return divide (lastseven,lastthirtyfive-lastseven)
Adjust the column names as needed.
Hi again,
I am grateful for your help.
I wıll send my page because ı am not solve this problem. It ıs so complicated now:(. I hope u can help me.
My aım:
If today 25.06.2020, (sum of total sales of 25.06.2020 to 19.06.2020) / ((sum of total sales 18.06.2020 to 22.05.2020) /4)
A = sum of total sales of 25.06.2020 to 19.06.2020
B = (sum of total sales 18.06.2020 to 22.05.2020)
A/(B/4)
so you don't want to compare the last seven days to the 28 days before that, but rather to their average. In that case just multiply by 4.
measure =
var today=max([date])
var lastseven = calculate(sum([Sales]),[date]>today-7)
var lastthirtyfive = calculate(sum([Sales]),[date]>today-35)
return divide (4*lastseven,lastthirtyfive-lastseven)
I also see that you have created all separate measures. Please don't do that. The above code has to go into the definition of your single measure. The variables are part of the measure definition.
I thınk smt is wrong on my page,
Maybe my problem is related in [Date]?
On the chart I want to see:
For example: Based on the 14th of May, the ratio of 4 * (8-14th of May total sales) to the sales of 7th May - 16th April. Likewise, I want to see the rate of 13 May. Like all the days of the moon
Don't use a date hierarchy in your facts table - use your Dates table for that. The facts table should have just the raw date field.
In Options and settings, under Current File.. Data load disable the "Auto Date/Time Hierarchy"
Perakende Karşılaştırmalı =
(IF(
ISFILTERED('Sayfa1'[Date]),
AVERAGEX(
DATESBETWEEN(
'Sayfa1'[Date],
(TODAY()-6),
(TODAY())
),
CALCULATE(SUM('Sayfa1'[Sales]))
)
)
)/
IF(
ISFILTERED('Sayfa1'[Date]),
SUMX(
DATESBETWEEN(
'Sayfa1'[Date],
(TODAY()-34),
(TODAY()-7)
),
CALCULATE(SUM('Sayfa1'[Sales]))
)/4
)
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 17 | |
| 11 | |
| 9 | |
| 5 | |
| 4 |
| User | Count |
|---|---|
| 31 | |
| 25 | |
| 21 | |
| 14 | |
| 12 |