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
Sharma0815
Helper II
Helper II

How to include the ALL function in the Medianx calculation using summarized virtual table columns

I am attempting to plot a histogram distribution of incidents by sum of interactions for a selected closed date range and region, using filters. I have created a calculated column to tally the sum of interactions for each incident. My goal is to calculate the median of the sum of interactions for all incidents closed within the selected date range and region, and to display this median as a line on a line and stacked column chart.

Here is the histogram I am trying to plot with the distribution of incidents by sum f interactions created bins and the  median value of the sum of interactions as a line for all incidents closed between 2/3 to 2/6 

Here I am expecting 27.5


 

Sharma0815_0-1676146691000.png

 




Data set

IncidentNote_DateInteractionsClosed_DateNote_Added_byRegion 
34211/23/202312/3/2023ITNorth
34211/24/202322/3/2023ITNorth
34211/24/202322/3/2023SalesNorth
34211/25/202342/3/2023ITNorth
34211/26/202322/3/2023ITNorth
34221/26/202322/4/2023ITWest
34221/27/202342/4/2023MarketingWest
34221/27/2023102/4/2023HRWest
34231/23/202372/5/2023HRSouth
34231/23/202312/5/2023ITSouth
34231/23/2023172/5/2023ITSouth
34241/28/202342/6/2023HREast
34241/29/202382/6/2023ITEast
34251/30/2023302/6/2023ITEast
34261/23/2023322/6/2023HREast
34271/24/2023502/6/2023HREast
34281/23/2023622/6/2023ITEast

Sharma0815_2-1676146910194.png

 

 

Sharma0815_1-1676146855305.png

 

SumofNotes =
SUMX (
FILTER ( ALL ( incident_interactions ), [incident] = EARLIER ( [incident] ) ),
incident_interactions[Interactions]
)

 

Median of Interactions =
VAR T1 =
SUMMARIZE(
incident_interactions,
incident_interactions[Incident],
"Sum of Notes", MIN( incident_interactions[SumofNotes] )
)
RETURN
MEDIANX(T1, [Sum of Notes] )




6 REPLIES 6
ppm1
Solution Sage
Solution Sage

This measure gets your expected 27.5 median across all incidents. Note that to get dynamic binning, you'll need a disconnected bin table (not a calculated column, unless you want static binning outside of filter context).

ppm1_0-1676213293359.png

 

Median Sum =
MEDIANX (
    DISTINCT ( incident_interactions[Incident] ),
    CALCULATE ( SUM ( incident_interactions[Interactions] ) )
)

 

Pat

Microsoft Employee

Thanks @ppm1 ,I tried your solution and attempted to plot it as a line; however, I expected it to be a straight line with a value of 27.50

Sharma0815_0-1676253690743.png

 

 

Ashish_Mathur
Super User
Super User

Hi,

Your question is not clear.  Could you put the data and workings in an MS Excel workbook (with your formulas, Pivot Tables and explanatory notes).  I will try to understand the logic from there and write the DAX formula.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur ,

I am trying to create a histogram to show the distribution of incidents based on the sum of interactions. My data set, called "incident_interactions", contains incidents data with the number of actions noted each day, as well as the incident's closed date. I have created a calculated column to sum up the interactions for each incident, for example, incident 3421 has 11 interactions.

 


This is my data set.

IncidentNote_DateInteractionsClosed_DateNote_Added_byRegion 
34211/23/202312/3/2023ITNorth
34211/24/202322/3/2023ITNorth
34211/24/202322/3/2023SalesNorth
34211/25/202342/3/2023ITNorth
34211/26/202322/3/2023ITNorth
34221/26/202322/4/2023ITWest
34221/27/202342/4/2023MarketingWest
34221/27/2023102/4/2023HRWest
34231/23/202372/5/2023HRSouth
34231/23/202312/5/2023ITSouth
34231/23/2023172/5/2023ITSouth
34241/28/202342/6/2023HREast
34241/29/202382/6/2023ITEast
34251/30/2023302/6/2023ITEast
34261/23/2023322/6/2023HREast
34271/24/2023502/6/2023HREast
34281/23/2023622/6/2023ITEast
 
Sum of interactions =
SUMX (
FILTER ( ALL ( incident_interactions ), [incident] = EARLIER ( [incident] ) ),
incident_interactions[Interactions]
)

 



Sharma0815_1-1676182390304.png

 

I have also created bins for the sum of interactions, with a bin size of 15. The goal is to plot a histogram that displays the number of incidents that fall into each bin and to add a median value line to the chart. The median value is calculated as the median of the sum of interactions for all incidents closed in the selected date range and region, and it is expected to be 27.50

 

Sharma0815_2-1676182568524.png

Sharma0815_3-1676182781354.png


I expect my measure to compute the median of the sum of interactions in the list.

Sharma0815_4-1676183205345.png

 



Median of Interactions =
VAR T1 =
SUMMARIZE(
incident_interactions,
incident_interactions[Incident],
"Sum of Notes", MIN( incident_interactions[SumofNotes] )
)
RETURN
MEDIANX(T1,[Sum of Notes])

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur ,

Unfortunately, I cannot share files through OneDrive or Google Drive as access to these sites is restricted for me. Is there an alternative method, such as emailing the files to you

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.