Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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:
Solved! Go to Solution.
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()
Hi @gillyr7
Create a measure and keep the interaction among the visuals as below
Measure = AVERAGE('Table'[Price])
Add them in a matrix.
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.
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.
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()
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
91 | |
87 | |
84 | |
68 | |
49 |
User | Count |
---|---|
131 | |
111 | |
96 | |
70 | |
67 |