The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have used these Dax formula to calculate Previous Week but results are incorrect, can someone please help me rectify this? Thanks in advance.
First Formula used populates column but values are incorrect.
Previous Week in Second Forumula shows blank Values
@ValtteriN Can you assist? I do not have lastWeek as a table to filter on, so I used calendar and here are my results.
Dax Formula:
Hi @Merle,
You can try to use the following formula to get the previous week amounts:
formula =
VAR currdate =
MAX ( Calendar[Date] )
VAR weekStart =
IF (
WEEKNUM ( currdate, 1 ) <> 1,
currdate - WEEKDAY ( currdate, 1 ) + 1,
DATE ( YEAR ( currdate ), 1, 1 )
)
RETURN
CALCULATE (
SUM ( Table[TOTAL_ACTIONS] ),
FILTER (
ALLSELECTED ( Table ),
YEAR ( [Date] )
= YEAR ( weekStart - 1 )
&& WEEKNUM ( [Date] , 1 )
= WEEKNUM ( weekStart - 1 , 1 )
)
)
Regards,
Xiaoxin Sheng
Hi Valtterin,
Thank you for your response. The results I am looking for is Actions for the last week to the current week values not the actual week num.
Hi,
Try using WEEKNUM e.g.
Proud to be a Super User!
User | Count |
---|---|
11 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
24 | |
14 | |
13 | |
10 | |
7 |