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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
arp2
Helper II
Helper II

Help with slicer measure

Team, I have three tables showing weekly forecast, capacity, and plan by discipline, Project, and Grouping. I've created measures for the Average of the Top 5 weeks (for Forecast) and Max of Capacity (for capacity). These are working fine with slicers on the page except the slicers for Office Location and Approval. Office Location and Approval are fields from the forecast table. I need help with the following:

  1. I want the measure for “AvgTop5Weeks” to show results for selected office locations and selected approval and
  2. I want the measure for “AvgTop5Weeks” to show results for weeks after a specified cutoff (say current week or next week)

Can you plz guide me?

DummyMar1 R0.pbix

 

5 ACCEPTED SOLUTIONS
Kaviraj11
Super User
Super User

For the 1st Problem - you can change the following Measure to 

 

SumFcstWeek = CALCULATE(SUM(ForecastTable[Forecast Hours]))
AvgTop5Weeks = AVERAGEX(TOPN(5,SUMMARIZE(ALLSELECTED(ForecastTable),ForecastTable[Week],"TotWeek",[SumFcstWeek]),[TotWeek],DESC),[TotWeek])



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

Proud to be a Super User!





View solution in original post

Thanks @Kaviraj11 would you be able to guide on the 2nd point?

View solution in original post

here is the DAX below:
you can use DateAdd function as well, to verify the result, you can create a calcualted column anf using the summarize part of the function to validate your result
AvgTop5Weeks =
AVERAGEX(TOPN(5,FILTER(SUMMARIZE(ALLSELECTED(ForecastTable),ForecastTable[Week],"TotWeek",[SumFcstWeek]
),ForecastTable[Week]<=TODAY()),[TotWeek],DESC),[TotWeek])



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

Proud to be a Super User!





View solution in original post

ForecastTable[Week]<=TODAY())

above expression will consider all records that are less than equal to today

If you want to do it by DAY,Month,YEAR, you can use

ForecastTable[Week]>=DATESINPERIOD(ForecastTable[Week], TODAY(), 11, DAY)



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

Proud to be a Super User!





View solution in original post

Thanks @Kaviraj11 this is working as required.....I wanted dates after today so I just changed the "less than" to greater than.

View solution in original post

9 REPLIES 9
Kaviraj11
Super User
Super User

Can you explain with an example? 

I would also recommend to create a DateDim or Calendar table. 

Could you mark first solution as accepted?




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

Proud to be a Super User!





I want the AvgTop5Weeks measure to calculate the average of top 5 weeks which are after a specified date. Currently it is calculating the average of top 5 weeks among all weeks listed in the table. Example, let's say I want the average of Top 5 weeks which are after week 28th March.

here is the DAX below:
you can use DateAdd function as well, to verify the result, you can create a calcualted column anf using the summarize part of the function to validate your result
AvgTop5Weeks =
AVERAGEX(TOPN(5,FILTER(SUMMARIZE(ALLSELECTED(ForecastTable),ForecastTable[Week],"TotWeek",[SumFcstWeek]
),ForecastTable[Week]<=TODAY()),[TotWeek],DESC),[TotWeek])



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

Proud to be a Super User!





In above, where and how do I specify the date after which I want the measure to calculate the average?

ForecastTable[Week]<=TODAY())

above expression will consider all records that are less than equal to today

If you want to do it by DAY,Month,YEAR, you can use

ForecastTable[Week]>=DATESINPERIOD(ForecastTable[Week], TODAY(), 11, DAY)



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

Proud to be a Super User!





Thanks @Kaviraj11 this is working as required.....I wanted dates after today so I just changed the "less than" to greater than.

@Kaviraj11 plz see above.....kindly let me know if this is not clear yet

Kaviraj11
Super User
Super User

For the 1st Problem - you can change the following Measure to 

 

SumFcstWeek = CALCULATE(SUM(ForecastTable[Forecast Hours]))
AvgTop5Weeks = AVERAGEX(TOPN(5,SUMMARIZE(ALLSELECTED(ForecastTable),ForecastTable[Week],"TotWeek",[SumFcstWeek]),[TotWeek],DESC),[TotWeek])



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

Proud to be a Super User!





Thanks @Kaviraj11 would you be able to guide on the 2nd point?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.