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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
gillyr7
Frequent Visitor

Keep Blank Rows After Filter And Create Average of all Others

Capture.JPG

I am having a trouble with a model I am building in Power BI Desktop. I have a table, and in the end, I am trying to calculate the average price grouped by Affiliation and Code.

 

The caveat, is that I need there to always be every Affiliation and every code regardless of the filters. Please see my picture I included. Each affiliation (A,B,C) has all three codes (1,2,3). Affilation 3 however, only has one of the payers. When I filter to Payer 'One', Affilation C goes away.

 

I am wondering if there is a way to keep Affiliation C and all three codes there regardless of the filter, and if it is missing, calculate the average of the others to throw into the blank cells. I tried Summarize but could not figure it out.

 

My formula to calculate the average price (it's actually median), is below:

CALCULATE(MEDIAN(Merge1[PRICE]),ALLEXCEPT(Merge1,Merge1[AffiliationCode],Merge1[Affiliation Level II]))
 
I can adjust this if needed.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

The answer is maybe.  It will depend on your slicers and if you made to that the table relationship has the security filters set to 1 way.

 

If your slicers are set up to filter based on the fields in your merge table, then only the number considered by my measure will be impacted.  The list of Key values will be unfiltered.

 

You mentioned a good point, the way my measure is set up. If a Key connects to no values it will return blank.  A Blank is different to a zero. So the question for you would be, do you want blanks to be zero?  If thats the case, add a "+ 0" after the SUM()

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @gillyr7 

Create a measure and keep the interaction among the visuals as below

Measure = AVERAGE('Table'[Price])

Add them in a matrix.

1.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

There are a few ways you could solve this.  If you want to make sure you get every single Afflication and Code, I would suggest building a table using PowerQuery that contains 1 row for every combination.

 

This table could be something as simple as a Key, which is a concatination of the Afflication and Code of that row, then having a column for those values separately.

 

In your merge1 table, include an extra field that uses the same concatination. You will now be able to link the Key table in a 1 to many relationship with your merge1 table.

 

From here you could have a measure that does a median of the result for each entry in this key table.  Such a measure might look like:

Median of Sums = MEDIANX(
	VALUES(KeyTable[Key]),
	SUM(Merge1[PRICE])
)

Thanks for the response. I will give this a try. I have slicers set up on my Merge1 table, will the price be filtered by the slicers when calculating on the key table?

 

Also, from your formula, it does not look like there is anything there for the missing values. For example, if you saw my screenshot, Affiliation C did not have Payer "1". If the slicer is selected to Payer "1", is there a way to have Affiliation C calculate the median for all affilations since C does not have any data? Thanks.

Anonymous
Not applicable

The answer is maybe.  It will depend on your slicers and if you made to that the table relationship has the security filters set to 1 way.

 

If your slicers are set up to filter based on the fields in your merge table, then only the number considered by my measure will be impacted.  The list of Key values will be unfiltered.

 

You mentioned a good point, the way my measure is set up. If a Key connects to no values it will return blank.  A Blank is different to a zero. So the question for you would be, do you want blanks to be zero?  If thats the case, add a "+ 0" after the SUM()

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

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.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.