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

Measures calculated based on slicer

Hi, 

 

I am trying to create a report which is for my finance team. I need to be able to project for the rest of the years income. To do this they take last weeks income and multiply it by the remaining weeks in the year and add it to the weeks already gone. E.G.

 

Week 3 = week 1 + week 2 + week 3 + (week 3 * (52-3))

Week 4 = week 1 + week 2 + week 3 + week 4 + (week 4 *(52-4)) etc. 

 

I have created measures for each of the weeks I just need to be able to make them change and automatically calculate based on the week number selection I make in a slicer. 

 

Many thanks for your help!

 

Josh 

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following steps to meet your requirement.

 

1. Create a week column, weekFY column, a weekname column and a fiscal year column.

 

week = WEEKNUM('table'[Date],1)

 

WeeKFY = 
VAR WeekStartinFY =
    WEEKNUM ( DATE ( YEAR('table'[Date]), 4, 1 ), 1 )
var max_date = MAX('table'[week])
RETURN
    IF (
        'table'[week] < WeekStartinFY,
        max_date -WeekStartinFY + 'table'[week] ,
        'table'[week] - WeekStartinFY +1      
)         

 

week name = CONCATENATE("Week ",'table'[WeeKFY])

 

Fiscal Year = 
IF('table'[Date]<DATE(YEAR('table'[Date]),3,31),YEAR('table'[Date]),YEAR('table'[Date])+1)

 

measure 1.jpg

 

2. Then we can create a measure,

 

Measure = 
var Date__ = MIN('table'[WeeKFY])
var year__ = MIN('table'[Fiscal Year])
var week_value = CALCULATE(SUM('table'[value]),FILTER(ALL('table'),'table'[WeeKFY]=Date__ && 'table'[Fiscal Year] = year__))
var grand_total = CALCULATE(SUM('table'[value]),FILTER(ALL('table'),'table'[WeeKFY]<=Date__ && 'table'[Fiscal Year] = year__))
return
grand_total + week_value * (52-Date__)

 

The result like this,

 

measure 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following steps to meet your requirement.

 

1. Create a week column, weekFY column, a weekname column and a fiscal year column.

 

week = WEEKNUM('table'[Date],1)

 

WeeKFY = 
VAR WeekStartinFY =
    WEEKNUM ( DATE ( YEAR('table'[Date]), 4, 1 ), 1 )
var max_date = MAX('table'[week])
RETURN
    IF (
        'table'[week] < WeekStartinFY,
        max_date -WeekStartinFY + 'table'[week] ,
        'table'[week] - WeekStartinFY +1      
)         

 

week name = CONCATENATE("Week ",'table'[WeeKFY])

 

Fiscal Year = 
IF('table'[Date]<DATE(YEAR('table'[Date]),3,31),YEAR('table'[Date]),YEAR('table'[Date])+1)

 

measure 1.jpg

 

2. Then we can create a measure,

 

Measure = 
var Date__ = MIN('table'[WeeKFY])
var year__ = MIN('table'[Fiscal Year])
var week_value = CALCULATE(SUM('table'[value]),FILTER(ALL('table'),'table'[WeeKFY]=Date__ && 'table'[Fiscal Year] = year__))
var grand_total = CALCULATE(SUM('table'[value]),FILTER(ALL('table'),'table'[WeeKFY]<=Date__ && 'table'[Fiscal Year] = year__))
return
grand_total + week_value * (52-Date__)

 

The result like this,

 

measure 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

 

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

danno
Resolver V
Resolver V

Hi, 

could you just confirm what type of calendar you are using, is it fiscal or a regular calendar? 

Anonymous
Not applicable

hi @danno , 

 

I am using a fiscal calendar but our weeks start from 30th March til 5th April is week 1 etc.

 

Thanks

 

I would start with this articel to make sure you are suing the right logic for week based time intelligence. 

https://www.sqlbi.com/articles/week-based-time-intelligence-in-dax/

There are some patterns in there for doing week based YTD calculations. 

i would create separate measures for the previous week, YTD and then combine those to get your projection.

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.