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
mollycat
Frequent Visitor

MAX Measure showing as a SUM on graph

Hello!

 

I have the following dataset where the Time_Slice_10 represents during which 10-minute period the event occurred. The Time_Slice_10_Count then totals the number of events that happened during that time. Note: in this example, the total is grouped by Facility.

FacilityEvent_TimeTime_Slice_10Event_DateTime_Slice_10_Count (calculated)
A2022-05-21 07:54:072022-05-21 07:50:002022-05-212
A2022-05-21 07:58:162022-05-21 07:50:002022-05-212
A2022-07-12 19:24:072022-07-12 19:20:002022-07-121
A2022-07-15 03:45:002022-07-15 03:40:002022-07-151

 

In Power BI, I am using the following Measures to calcuate the Time_Slice_10_Count:

  • CALC1 = COUNT('Database.Table'[Time_Slice_10])
  • CALC2 = MAXX(
    KEEPFILTERS(VALUES('Database.Table'[Event_Date])),
    CALCULATE([CALC1]))
 
The problem I am running into is that on my graph I want to see the MAX value of the Time_Slice_10_Count per day, but the Measure is summing to show me a total of 4 for the date of 2022-05-21, instead of 2. Since it is a Measure, I cannot change the aggregation type in the visualization like I could with a Column. I am trying to do these calculations as Measures so that the values can be dynamic depending on other filtered values on the page. For example, in this example I am grouping by the Facility, but I'd also like the option to group and show MAX values by Area, Region, or any other filter. My understanding is that if I calculate via Columns, I need to indicate how to do the slicing and dicing in the calculation itself rather than using the page filters.
 
Any advice on this is greatly appreciated!
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @mollycat ,

Here are the steps you can follow:

1. Create measure.

Time_Slice_10_Count (calculated) =
var _10min=MAX('Table'[Time_Slice_10]) +TIME(0,10,0)
return
COUNTX(FILTER(ALL('Table'),'Table'[Facility]=MAX('Table'[Facility])&&'Table'[Event_Time]<=_10min&&'Table'[Event_Time]>='Table'[Time_Slice_10]&&'Table'[Event_Date]=MAX('Table'[Event_Date])
),[Facility])
Measure =
MAXX(FILTER(ALL('Table'),'Table'[Facility]=MAX('Table'[Facility])&&'Table'[Event_Date]=MAX('Table'[Event_Date])),[Time_Slice_10_Count (calculated)])

2. Result:

vyangliumsft_0-1658753798733.png

If you need pbix, please click here.

 

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

View solution in original post

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

Hi  @mollycat ,

Here are the steps you can follow:

1. Create measure.

Time_Slice_10_Count (calculated) =
var _10min=MAX('Table'[Time_Slice_10]) +TIME(0,10,0)
return
COUNTX(FILTER(ALL('Table'),'Table'[Facility]=MAX('Table'[Facility])&&'Table'[Event_Time]<=_10min&&'Table'[Event_Time]>='Table'[Time_Slice_10]&&'Table'[Event_Date]=MAX('Table'[Event_Date])
),[Facility])
Measure =
MAXX(FILTER(ALL('Table'),'Table'[Facility]=MAX('Table'[Facility])&&'Table'[Event_Date]=MAX('Table'[Event_Date])),[Time_Slice_10_Count (calculated)])

2. Result:

vyangliumsft_0-1658753798733.png

If you need pbix, please click here.

 

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

@mollycat ,

 

Calculate(Sumx(Summarize(Table, Table[Facility], Table[Event_Date]), Calculate(Lastnonblankvalue(Table[Event_Date]), Count(Table[Event_Date]) ) ) , allexcept(Table, Table[Facility], Table[Event_Date]) )

 

or check if this can help

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

 

Hi @amitchandak, thank you for your response. Unfortunately this formula is still giving me the SUM of the values, rather than the MAX. I've written this measure which seems to get me pretty close but is also not completely working:

Measure = MAXX('Table',COUNT('Table'[Time_Slice_10])))
 
This measure correctly calculates the number of Time_Slice_10 events, but then it does not aggregate properly to calculate the MAX value. Example:
FacilityEvent_DateTime_Slice_10Measure

A

2022-07-192022-07-19 20:00:001

A

2022-07-192022-07-19 05:10:004
A2022-07-192022-07-19 05:50:001
A2022-07-192022-07-19 06:40:0011
A2022-07-192022-07-19 07:10:002

Based on the data in the table this Measure is calculating correctly (ie: there are 11 rows of events that fall into the 2022-07-19 06:40:00 time slice, two events in the 2022-07-19 07:10:00 time slice, etc.). However, when I remove the Time_Slice_10 column, I expect the Measure to recalculate based on the columns in the table to show me the MAX value of 11. Instead it does the sum of these and returns 19 (1+4+1+11+2):

FacilityEvent_DateMeasure
A2022-07-1919

 

Again, I really appreciate your help and response on this! 🙂

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.