Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculating week differences

Hi, 

I have created a measure to calculate this week compared to last week. But when this or last week is blank its calcuting 0 versus this or last weeks number. How can I get around this? I have tried using a IF(HASONE VALUE statement the below measure but returns "Blank" unconditionally

IF(HASONEVALUE('Dato_Kørsel'[Date]);
AVERAGE([Responstid_kørsel (min.)]) - CALCULATE(AVERAGE([Responstid_kørsel (min.)]);
FILTER(ALL(Dato);Dato[Ugenr.] = WEEKNUM(TODAY();2) -1 &&
Dato[År] = SELECTEDVALUE(Dato[År])));BLANK())

Thanks,

Mikkel
1 ACCEPTED SOLUTION
RobbeVL
Impactful Individual
Impactful Individual

Hi,

 

Hope this helps:
Might have done an overkill on variables though 🙂

 

Difference Last week = 
VAR
CrntWeek = WEEKNUM(TODAY())
VAR
CRNTVAL = CALCULATE(SUM('Table'[Value]); 'Table'[Week] = CrntWeek)
VAR
PrevVAL = CALCULATE(SUM('Table'[Value]); 'Table'[Week] = CrntWeek-1)
VAR
WeekDIFF = CRNTVAL - PrevVAL
RETURN

IF(CRNTVAL = BLANK() || PrevVAL = BLANK() ; BLANK() ; WeekDIFF)

View solution in original post

4 REPLIES 4
RobbeVL
Impactful Individual
Impactful Individual

Hi there,

 

Just to have an idea what your expected result is.

Are you creating a KPI card? a table ? 

 

Anonymous
Not applicable

Hi Robbie 

Sure, forgot that. Its a KPI card which now shows 7.7 as it is calculating difference between week 47 (7.7) and 46 (which doesnt have data). I want it to show BLANK if the week before (46) or the current week (47) is without value. 

 
RobbeVL
Impactful Individual
Impactful Individual

Hi,

 

Hope this helps:
Might have done an overkill on variables though 🙂

 

Difference Last week = 
VAR
CrntWeek = WEEKNUM(TODAY())
VAR
CRNTVAL = CALCULATE(SUM('Table'[Value]); 'Table'[Week] = CrntWeek)
VAR
PrevVAL = CALCULATE(SUM('Table'[Value]); 'Table'[Week] = CrntWeek-1)
VAR
WeekDIFF = CRNTVAL - PrevVAL
RETURN

IF(CRNTVAL = BLANK() || PrevVAL = BLANK() ; BLANK() ; WeekDIFF)
Anonymous
Not applicable

Thanks Robbie! 

It works perfectly!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors