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
manalla
Helper V
Helper V

Static Median line in a line graph irrespective of slicers selection

Hi,

 

I have a line graph which shows percentage values over span of 4 months. We have customer name as filter/slicer, when specific customer is selected visual changes showing percentage values on line only for the customer. Default behaviour.

 

Now we need to show a static line - which will show the Median values for all the cutomers for four months by month. This Median line needs to be static all the time, irrespective of filter/slicer selection. Sample data given below.

 

DatePercentageCustomer
3/31/20198.60%A
3/31/20198.34%B
3/31/20194.16%C
4/30/20193.82%A
4/30/20195.59%B
4/30/201910.47%C
5/31/201912.85%A
5/31/20194.86%B
5/31/201912.14%C
6/30/20197.69%A
6/30/20192.47%B
6/30/20193.72%C

 

I think, i will need a fourth column like below: ( only then my Median line can be static irresepctive of customer selection)

DatePercentageCustomerMedian
3/31/20198.60%A8.34%
3/31/20198.34%B8.34%
3/31/20194.16%C8.34%
4/30/20193.82%A5.59%
4/30/20195.59%B5.59%
4/30/201910.47%C5.59%
5/31/201912.85%A12.14%
5/31/20194.86%B12.14%
5/31/201912.14%C12.14%
6/30/20197.69%A3.72%
6/30/20192.47%B3.72%
6/30/20193.72%C3.72%

 

Please help with any suggestions.

 

Thanks

Manoj

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

View solution in original post

Hey Mate,

I took the solution is a totally different direction with this solve but here we go.

SourceDesire.PNG

To the achieve the output I split the medians out into separate tables using the DAX SUMMARIZE

DateMedian = SUMMARIZE(Data, Data[Date], "Median3", MEDIAN(Data[Percentage]))
CategoryMedian = SUMMARIZE(Data, Data[Customer Category], "Median4", MEDIAN(Data[Percentage]))


These two separate tables are now linked back to the Source table (Data) via the Data'Date' and Data'Customer Category' respectively.
RelationshiptoMedian.PNG
**Please note the cross filter direction is set to both.

 

Now just combine them into one table and Bob's your uncle. Desired Output created and you can place a slicer for either Customer and or Customer Category and slice and dice to your liking :).

 

Hope this helps mate. It was a good challenge 🙂

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

Hi @Ashish_Mathur ,

 

Thanks for the solution, it worked. There is an additonal ask for which i tried, but couldnt solve.

Adding an additional field to pevious scenario. Now user wants to see one more additional line on the graph which would show the Median of selected product's Category. With my understading i have put the expected dataset below:

 

Date

PercentageCustomerMedianCustomer CategoryCategory Median
3/31/20198.60%A6.81%Bikes8.47%
3/31/20198.34%B6.81%Bikes8.47%
3/31/20194.16%C6.81%Scooter4.72%
3/31/20195.27%D6.81%Scooter4.72%
4/30/20193.82%A7.10%Bikes4.71%
4/30/20195.59%B7.10%Bikes4.71%
4/30/201910.47%C7.10%Scooter9.54%
4/30/20198.60%D7.10%Scooter9.54%

 

I have tried in similar lines based on your MedianX defintion and formula, but not able to acheive the rigth result.

Can you please help with this?

 

Thanks

Manoj

Hi,

I used these 2 measures

Measure = SUM(Data[Percentage])
category median = MEDIANX(CALCULATETABLE(VALUES(Data[Customer]),ALL(Data[Customer])),[Measure])

Hope this helps.

Untitled.png


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

Hi All, any leads or help here?

 

Thanks
Manoj

Hey Mate,

I took the solution is a totally different direction with this solve but here we go.

SourceDesire.PNG

To the achieve the output I split the medians out into separate tables using the DAX SUMMARIZE

DateMedian = SUMMARIZE(Data, Data[Date], "Median3", MEDIAN(Data[Percentage]))
CategoryMedian = SUMMARIZE(Data, Data[Customer Category], "Median4", MEDIAN(Data[Percentage]))


These two separate tables are now linked back to the Source table (Data) via the Data'Date' and Data'Customer Category' respectively.
RelationshiptoMedian.PNG
**Please note the cross filter direction is set to both.

 

Now just combine them into one table and Bob's your uncle. Desired Output created and you can place a slicer for either Customer and or Customer Category and slice and dice to your liking :).

 

Hope this helps mate. It was a good challenge 🙂

Aree
Resolver I
Resolver I

Just an idea to caulate the median as a a measure using MEDIANX() but the table you are feeding it will be using the ALL(). 

This way no matter how the user changes the slicers the median will always be the median of the entire table and not a subset based on a slicer.

 

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.