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
vazou19
Regular Visitor

Calculate average by group which is unaffected by date slicer

Hi there,

 

I am new here and I need your help.

 

Let's say we have the following dataset:

 

DateNameShiftMeasure
2/06/2022Nick

morning 

34
2/06/2022Georgemorning45
2/06/2022Lisamorning 23
2/06/2022Marymorning14
3/06/2022Nick

night

35
3/06/2022Georgenight24
3/06/2022Lisanight34
3/06/2022Marynight17

   

 

I would like a measure for conditional formatting purposes. So I want the all-time average of each type of shift. Then on my performance report, I want to show their stats in green color if they are above the average and red if they are below. In other words, if my report is for 3/06/2022, I want this measure to give me the all-time average of night shifts only and be unaffected by the selected date "3/06/2022". 
 
I hope it makes sense.
 
Thank you in advance.


        

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @vazou19 ,

I created some data:

vyangliumsft_0-1662356891036.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
DISTINCT('Table'[Date])

vyangliumsft_1-1662356891039.png

2. Create measure.

AVG =
var _select=SELECTEDVALUE('Table 2'[Date])
var _selectshift=
MAXX(FILTER(ALL('Table'),'Table'[Date]=_select),[Shift])
return
AVERAGEX(FILTER(ALL('Table'),'Table'[Date]<>_select&&'Table'[Shift]=_selectshift),[Measure])
color =
IF(
    MAX('Table'[Measure]) >=[AVG],"green","red")

3. Select [Measure] – Conditional formatting – Background color.

vyangliumsft_2-1662356891042.png

4. Format style – Field value – [color]

vyangliumsft_3-1662356891044.png

5. Result:

vyangliumsft_4-1662356891049.png

If you need pbix, please click here.

Calculate average by group which is unaffected by date slicer.pbix

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@vazou19 , a new measure

Calculate(AverageX(Summarize(Table,Table[Date], Table[Name], "_1",[Measure]) , [_1]), Filter(all(Table), Table[Shift] = max(Table[Shift]) ))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you for the prompt reply.

 

However, it doesn't let me write the [measure]. It gives me only the [date] and [name] options. Any thoughts?

 

Thanks

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.