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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Raneesh
Frequent Visitor

How to get previous week with an another measure

Tying to get previouse week penetration, I'm getting error. Could you please assist.

 

#Prior Week Penetration =
var _Penetration=DIVIDE( [#Count of customer] , 'Occupancy tracker'[#Occupancy] ,0)
return
IF(ISBLANK(_Penetration),0,_Penetration)
var PriorWeek = SELECTEDVALUE ( _Penetration ) -1

RETURN
CALCULATE(
SUM ( _Penetration ),
ALL ( 'Calendar'[Week of Year] ),
'Calendar'[Week of Year] = PriorWeek
)
1 ACCEPTED SOLUTION
tamerj1
Community Champion
Community Champion

Hi @Raneesh 
Actually the formula I have messaged you was almost correct, the only mistake is switching between Numerator and Denominator. This one shall work 

%Previous Week Penetration =
VAR PriorWeek =
    MAX ( 'Calendar'[Week of Year] ) - 1
VAR Customers =
    CALCULATE (
        DISTINCTCOUNT ( leadlist[Unit Number] ),
        'Calendar'[Week of Year] = PriorWeek
    )
VAR Occupancy =
    CALCULATE (
        SUM ( 'Occupancy tracker'[Total Occupied] ),
        'Calendar'[Week of Year] = PriorWeek
    )
RETURN
    DIVIDE ( Customers, Occupancy )

View solution in original post

12 REPLIES 12
tamerj1
Community Champion
Community Champion

@Raneesh 
[#Count of customer] and [#Occupancy] are coulmns or measures?

Yes.

#Count of customer = var _Customer=DISTINCTCOUNT(leadlist[Unit Number])
return
IF(ISBLANK(_Customer),0,_Customer)
 
#Occupancy = CALCULATE(SUM('Occupancy tracker'[Total Occupied]))
tamerj1
Community Champion
Community Champion

Then this should work

#Prior Week Penetration =
VAR PriorWeek =
    MAX ( 'Calendar'[Week of Year] ) - 1
RETURN
    CALCULATE (
        DIVIDE ( [#Count of customer], [#Occupancy], 0 ),
        'Calendar'[Week of Year] = PriorWeek
    )

I'm expecting an output like below.

 

 Week Number123
PenetrationCurrent WeekPrevious WeekCurrent WeekPrevious WeekCurrent WeekPrevious Week
Building Name       
Balqis 405495
South Residences 7087118

It still shows zero value.

 

Raneesh_0-1647239232542.png

 

tamerj1
Community Champion
Community Champion

Hi @Raneesh 

You can try

#Prior Week Penetration =
VAR _Penetration =
    DIVIDE ( [#Count of customer], 'Occupancy tracker'[#Occupancy], 0 )
VAR _PenetrationChecked =
    IF ( ISBLANK ( _Penetration ), 0, _Penetration )
VAR PriorWeek =
    MAX ( 'Calendar'[Week of Year] ) - 1
RETURN
    CALCULATE (
        _PenetrationChecked,
        REMOVEFILTERS ( 'Calendar' ),
        'Calendar'[Week of Year] = PriorWeek
    )

Hi @tamerj1 , it returning zero

 

Raneesh_0-1647168918281.png

 

tamerj1
Community Champion
Community Champion

Hi @Raneesh 

seems I forgot to use SUM

#Prior Week Penetration =
VAR Occupancy =
    SUM ( 'Occupancy tracker'[#Occupancy] )
VAR _Penetration =
    DIVIDE ( [#Count of customer], Occupancy, 0 )
VAR PriorWeek =
    MAX ( 'Calendar'[Week of Year] ) - 1
RETURN
    CALCULATE (
        _Penetration,
        REMOVEFILTERS ( 'Calendar' ),
        'Calendar'[Week of Year] = PriorWeek
    )

@tamerj1 

 

Do you want to shift both the numerator and the denominator one week back? Yes. exactly.

 

tamerj1
Community Champion
Community Champion

Hi @Raneesh 
Actually the formula I have messaged you was almost correct, the only mistake is switching between Numerator and Denominator. This one shall work 

%Previous Week Penetration =
VAR PriorWeek =
    MAX ( 'Calendar'[Week of Year] ) - 1
VAR Customers =
    CALCULATE (
        DISTINCTCOUNT ( leadlist[Unit Number] ),
        'Calendar'[Week of Year] = PriorWeek
    )
VAR Occupancy =
    CALCULATE (
        SUM ( 'Occupancy tracker'[Total Occupied] ),
        'Calendar'[Week of Year] = PriorWeek
    )
RETURN
    DIVIDE ( Customers, Occupancy )

Thank you soo much @tamerj1 .

Your extended support resolved my concern. 👍

Even now I'm geetting zero.

Thanks for your effort. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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