Forum Discussion
Calculating weekly running sum
Hi Wilson,
Thank you for your response.
Adding week number to the table seems like a good idea. However, unfortunately, I could achieve correct result using this approach. I have tried to:
- filter SNAP_DT <= MAX(dim_snapshot_calendar[SNAP_DT])
- calculate sum aggregated by snap week number
For every selected snap_dt.
I have tried some approaches, for example:
fact_revenue[NN YQ CY v2 snap_week] =
VAR maximus = MAX ( dim_snapshot_calendar[SNAP_DT] )
VAR totalSplit = CALCULATE ( SUM ( fact_revenue[revenue] ),
dim_snapshot_calendar[SNAP_DT] <= maximus )
return
SUMX(
SUMMARIZE ( fact_revenue_v2,
dim_snapshot_calendar[SNAP_WEEK_NUM] )
,totalSplit)
It returns only the value for the selected SNAP_DT and not the sum of all SNAP_DTs within the same SNAP_WEEK_NUM, where SNAP_DT <= selected SNAP_DT.
If I were to achieve simillar results using SQL, it would be:
SELECT fact_revenue[snap_week_num], SUM(fact_revenue[revenue])
FROM fact_revenue
WHERE fact_revenue[snapshot_date] > '2024-02-07'
GROUP BY fact_revenue[snap_week_num]
;
Could you maybe tell me, how to build an analogous DAX measure?
Thank you
- Wilson_1 year ago
Memorable Member
mkaol,
Can you please share a sample pbix file? (If you don't know how, please check the pinned thread in the forum.) It would make debugging your issue easier. 🙂
- mkaol1 year agoFrequent Visitor
Hi Wilson,
I have prepared a pbix file recreateing the Lakehouse and Semantic Model built in Fabric. I have uploaded the file to wetransfer: https://we.tl/t-HcbGv4nD2m. Please let me know, if the link is expired.
Thank you