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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Grouping in Matrix is Strange

I have simple dataset and my calculations are around specialty. So I always group results by specialty. When I tried to display the measures I created they show calculations correctly if the first column is Specialty. As soon as I add Provider ID field to the Rows section , measures give the total of all data not per Specialty 

 

2019-04-03_16-29-17.png

The three measures I created are: 
 
Number of Unique Claims COMM = CALCULATE(DISTINCTCOUNT(Sheet1[ClaimNo]),FILTER(ALLEXCEPT(Sheet1,Sheet1[Specialty]),Sheet1[MA/COM]="COM"))
 
 
Number of Unique Claims MA = CALCULATE(DISTINCTCOUNT(Sheet1[ClaimNo]),FILTER(ALLEXCEPT(Sheet1,Sheet1[Specialty]),Sheet1[MA/COM]="MA"))
 
Average CMS = CALCULATE(AVERAGE(Sheet1[Proc Code Industry Distribution/Specialty]),ALLEXCEPT(Sheet1,Sheet1[Specialty]))

 

 

Here is the source file of the report:

 

https://drive.google.com/file/d/1WGDpRR0z-_n7aYzDHYF7IQRdmWtG_1Fg/view?usp=sharing

 

 

 

Am I doing something wrong 😞 ?

 

Thanks

1 ACCEPTED SOLUTION


@Anonymous wrote:

@d_gosbell  thank you for the reply. Your suggestion will be perfect if my client does not require the Provider ID to be included in the Matrix visual at the beginning before Specialty . 


Oh, sorry - I think I misunderstood what you were expecting to see in the second table. 

 

I believe that what you are actually seeing is an issue with ALLEXCEPT where it strips off even implied crossfilters. Probably a safer pattern to use is a combination of ALL and VALUES

 

eg

 

Number of Unique Claims COMM = CALCULATE(DISTINCTCOUNT(Sheet1[ClaimNo]),ALL(Sheet1),VALUES(Sheet1[Specialty]),Sheet1[MA/COM]="COM")

 

The SQLBI guys have a blog on this topic, the last few paragraphs summarize this issue

https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/

View solution in original post

5 REPLIES 5
d_gosbell
Super User
Super User

I think you are possibly over complicating things here, I'm not sure why you have added the ALLEXCEPT calls, but I think the calcs will work fine without them. When you have the specialty on the row it will naturally group by that column.

 

eg.

 

Number of Unique Claims COMM = CALCULATE(DISTINCTCOUNT(Sheet1[ClaimNo]),Sheet1[MA/COM]="COM")
 
Number of Unique Claims MA = CALCULATE(DISTINCTCOUNT(Sheet1[ClaimNo]),Sheet1[MA/COM]="MA")
 
Average CMS = AVERAGE(Sheet1[Proc Code Industry Distribution/Specialty])
Anonymous
Not applicable

@d_gosbell  thank you for the reply. Your suggestion will be perfect if my client does not require the Provider ID to be included in the Matrix visual at the beginning before Specialty . 


@Anonymous wrote:

@d_gosbell  thank you for the reply. Your suggestion will be perfect if my client does not require the Provider ID to be included in the Matrix visual at the beginning before Specialty . 


Oh, sorry - I think I misunderstood what you were expecting to see in the second table. 

 

I believe that what you are actually seeing is an issue with ALLEXCEPT where it strips off even implied crossfilters. Probably a safer pattern to use is a combination of ALL and VALUES

 

eg

 

Number of Unique Claims COMM = CALCULATE(DISTINCTCOUNT(Sheet1[ClaimNo]),ALL(Sheet1),VALUES(Sheet1[Specialty]),Sheet1[MA/COM]="COM")

 

The SQLBI guys have a blog on this topic, the last few paragraphs summarize this issue

https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/

Anonymous
Not applicable

Thank you @d_gosbell  for the formula. it works.. can you please explain to me what VALUE function does it this context? 

 

Thank you again 


@Anonymous wrote:

Thank you @d_gosbell  for the formula. it works.. can you please explain to me what VALUE function does it this context? 

 


The VALUES function brings back the list of distinct specialities in the current filter context. So the ALL(Sheet1) strips all filters from the Sheet1 table and VALUES(Sheet1[Specialty]) then brings back just the current distinct set of Specialities. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.