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

Back dated calculation by week. 12 weeks -(minus) 24 weeks rolling with respect to change year.

I'm trying to calculate retaintion % by week. 

Challegne I'm facing: When years change, formula is not taking in account back dated week while calculating. 12 week - 24 weeks.
In below image when year is 2018 week 2 show 100%. Ideally it go back 12 week and 24 weeks from week 2(2018) for calculation. So, From week 43 (2017) to week 2 (2018) and same for  24 weeks, week 31(2017) to week2(2018).

 

Formulas:

1. Draw on graph: Retain % = 1-DIVIDE([Total1],[Total Final OutPut],0)

 

2. Total1=(
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Week]),'Dummy'[Week]<=MAX('Dummy'[Week])))
-
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Week]),
'Dummy'[Week]>=MAX('Dummy'[Week])-12 &&
'Dummy'[Week]<=MAX('Dummy'[Week]) )))
-
(
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Week]),'Dummy'[Week]<=MAX('Dummy'[Week])))
-
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Week]),'Dummy'[Week]>=MAX('Dummy'[Week])-24 &&
'Dummy'[Week]<=MAX('Dummy'[Week]))
))
 

3. Total Final OutPut = IF( NOT ISFILTERED('Dummy'[Week]),
CALCULATE(
COUNTAX(
FILTER(VALUES('Dummy'[Consignee] ),[Consignee MCount]),[Consignee MCount])),
CALCULATE(
COUNTAX(
FILTER(VALUES('Dummy'[Consignee] ),[Consignee MCount] >1),[Consignee MCount]),
FILTER(ALL('Dummy'[Week]),
'Dummy'[Week]<=MAX('Dummy'[Week])
)
))

4. Consignee  MCount = COUNTA('Dummy'[Consignee])

 

Capture.JPG

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

I would suggest you add an index column to sort the order of weeks per year.

 

In query editor mode, add a custom column.

WeekNum=[Year]*100+[Week of Year]

1.PNG

 

Then, add an index column.

2.PNG

 

Instead of referring to the [Week] column in each measure, please replace it with the [Index] column. 

For example:

Total1=(
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),'Dummy'[Index]<=MAX('Dummy'[Index])))
-
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),
'Dummy'[Index]>=MAX('Dummy'[Index])-12 &&
'Dummy'[Index]<=MAX('Dummy'[Index]) )))
-
(
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),'Dummy'[Index]<=MAX('Dummy'[Index)))
-
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),'Dummy'[Index]>=MAX('Dummy'[Index])-24 &&
'Dummy'[Index]<=MAX('Dummy'[Index]))
))

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

Would you please share some sample data to help us better understand above formulas?

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-yulgu-msft

 

Thanks for reply.

 

uploaded sample .

https://nofile.io/f/rrxXFYGJKRs/New+Challenge1.pbix

Hi @Anonymous,

 

I would suggest you add an index column to sort the order of weeks per year.

 

In query editor mode, add a custom column.

WeekNum=[Year]*100+[Week of Year]

1.PNG

 

Then, add an index column.

2.PNG

 

Instead of referring to the [Week] column in each measure, please replace it with the [Index] column. 

For example:

Total1=(
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),'Dummy'[Index]<=MAX('Dummy'[Index])))
-
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),
'Dummy'[Index]>=MAX('Dummy'[Index])-12 &&
'Dummy'[Index]<=MAX('Dummy'[Index]) )))
-
(
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),'Dummy'[Index]<=MAX('Dummy'[Index)))
-
CALCULATE([ConsigneeCount],
FILTER(ALL('Dummy'[Index]),'Dummy'[Index]>=MAX('Dummy'[Index])-24 &&
'Dummy'[Index]<=MAX('Dummy'[Index]))
))

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-yulgu-msft

 Thanks for your time and helping me out.

that really work , Thums up..Smiley Very Happy

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.