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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Dax comparing current week to lastweek

Hi,

I want to find out the Reorder rate Measure in the following table.

Capture.JPG

The Logic Reorder rate Measure is as follows,

for week no 2: Re Ordered Outlets in week 2 / No of Unique Outlets in previous week i.e week 1, (600/1110) *100 = 55%

for week no 3: Re Ordered Outlets in week 3 / No of Unique Outlets in previous week i.e week 2, (1280/1700) *100 = 76%

for week no 4: Re Ordered Outlets in week 4 / No of Unique Outlets in previous week i.e week 3, (1610/1950) *100 = 83%

for week no 5: Re Ordered Outlets in week 5 / No of Unique Outlets in previous week i.e week 4, (2010/2800) *100 = 72%

 

Thanks

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , You can work like

 

This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week ]=max('Date'[Week ])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week ]=max('Date'[Week ])-1))

 

But prefer week rank, else it will not work across year

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1 //Monday Week

or

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1 //Sunday Week

 

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)

This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

refer

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

https://www.youtube.com/watch?v=7Jc3D4iaTqs

Anonymous
Not applicable

Hi @amitchandak 

 

The below last week formulae working fine on normal sum but when use this formulae over cumulative sum it not working.

Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week ]=max('Date'[Week ])-1))

 

 

Thank you.

 

Cumulative till last week

Cumm Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week ]<=max('Date'[Week ])-1))

AlB
Super User
Super User

Hi @Anonymous 

You can create a calculated column in the table you show:

 

Reorder Rate =
VAR previousweek_ = Table1[week No] - 1
VAR uniqueOutletsPreviousWeek_ =
    CALCULATE (
        DISTINCT ( Table1[No of Unique Outlets] ),
        Table1[Week No] = previousweek_,
        ALL ( Table1 )
    )
RETURN
    100 * DIVIDE ( Table1[Re Ordered Outlets], uniqueOutletsPreviousWeek_ )

 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

MFelix
Super User
Super User

Hi @Anonymous ,

 

You need to use a measure similar to this one:

 

Reorder Date =
Var week_selected = SELECTEDVALUE (Table[Week])
Return
DIVIDE(SUM(Table[UniqueOutletes]); CALCULATE(SUM(Table[Re Orderred Outlets); FILTER(ALL(Table[Week]);Table[Week] = week_selected -1))

 

You may need to change the sum to a count or distintct count depending on your model settinsgs


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.