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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jts_
Helper I
Helper I

HELP!! Measure show comparison between selected values and other categories

Hi, I have a simple table that contains state, county, and growth rates.
I need to create a measure in Power BI that allows the visualization would change dynamically for comparison.

 

In the project scope, there are 3 states in total. I want each state's average growth rate to stay on the visualization all the time.

In addition, if there is a county is being filtered, this measure would return the average growth rate of each state PLUS the growth rate of the selected county.

 

Below is an example of the data:

StateCounty_NameCountyStateGrowthRate
ArkansasBaxter CountyBaxter County Arkansas2.0%
ArkansasAshley CountyAshley County Arkansas3.0%
ArkansasArkansas CountyArkansas County Arkansas1.5%
KentuckyAdair CountyAdair County Kentucky1.7%
KentuckyAllen CountyAllen County Kentucky3.2%
KentuckyAnderson CountyAnderson County Kentucky6.8%
VirginiaAccomack CountyAccomack County Virginia10.0%
VirginiaAlbemarle CountyAlbemarle County Virginia0.5%
VirginiaAlleghany CountyAlleghany County Virginia6.0%

 

 

If Allen County is filtered, I'd like this measure to show the average rate of each state with Allen County in the comparison.

Arkansas6.5%
Kentucky3.9%
Virginia5.5%
Allen County3.2%


Explainer in photo format:

Screenshot 2023-12-07 164658.png

 

 

 

 

Thank you in advance!! I appreciate all your insights!

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @jts_ ,

 

Since dynamic tables are not supported in PBI Desktop, your expected result cannot be achieved by presenting the State column and the selected County_Name column on a single column.

(1) My test data is the same as yours.

(2) We create a new table.

Table 2 = 
VALUES('Table'[State])

(3) We can create a measure.

Measure = 
var _rate=CALCULATE(SUM('Table'[GrowthRate]),FILTER(ALL('Table'),'Table'[State]=MAX('Table 2'[State])))
var _rows=COUNTROWS(FILTER(ALL('Table'),'Table'[State]=MAX('Table 2'[State])))
return DIVIDE(_rate,_rows,0)

(4)Then the result is as follows.

vtangjiemsft_0-1702363648727.png

Best Regards,

Neeko Tang

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

2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @jts_ ,

 

Since dynamic tables are not supported in PBI Desktop, your expected result cannot be achieved by presenting the State column and the selected County_Name column on a single column.

(1) My test data is the same as yours.

(2) We create a new table.

Table 2 = 
VALUES('Table'[State])

(3) We can create a measure.

Measure = 
var _rate=CALCULATE(SUM('Table'[GrowthRate]),FILTER(ALL('Table'),'Table'[State]=MAX('Table 2'[State])))
var _rows=COUNTROWS(FILTER(ALL('Table'),'Table'[State]=MAX('Table 2'[State])))
return DIVIDE(_rate,_rows,0)

(4)Then the result is as follows.

vtangjiemsft_0-1702363648727.png

Best Regards,

Neeko Tang

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

@jts_ , You need a disconnected table for that. Assume you have measure m1

 

then have new measure

m2= calculate([m1], filter(Table, Table[State] in values(State[State]) )

 

or

 

m2= calculate([m1], keepvalues( Table[State] in values(State[State]) )


Compare Categorical Data Using Slicers, Compare Two Brands/Categories/Cities: https://youtu.be/exN4nTewgbc

Need of an Independent/disconnected Table in Power BI - Exclude: https://youtu.be/lOEW-YUrAbE

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.