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
ccyangdi
Employee
Employee

Strange result for ALLEXCEPT

script for the 4 measures are as below:
TotalIdByVersion = CALCULATE(DISTINCTCOUNT(Demo[Id]), ALLEXCEPT(Demo, Demo[Version]))
TotalIdByVersionAndTime = CALCULATE(DISTINCTCOUNT(Demo[Id]), ALLEXCEPT(Demo, Demo[Timestamp], Demo[Version]))
TotalIdByTime = CALCULATE(DISTINCTCOUNT(Demo[Id]), ALLEXCEPT(Demo, Demo[Timestamp]))
TotalId = CALCULATE(DISTINCTCOUNT(Demo[Id]), ALLSELECTED(Demo[Vertical], Demo[SubVertical], Demo[SubSub]))
 
 
We want to get the total distinct [Id] count by [Version], which will be filtered by [Timestamp].
The measure TotalIdByVersion was working well without filtering by [Timestamp], so I add [Timestamp] to it to get the number I want. 
 
For version 1.10, total distinct [Id] without [Timestamp] filtering should be 5131, with [Timestamp] 1/5/2020 - 1/18/2020 should be 4354 (the number we want). We can see in screenshot 1 & 2, without filtering by Version slicer, the TotalIdByVersionAndTime in top table is correct, but in the lower table when extending to next level, the number is showing 211 (Q1: how did this happen and how can I get the correct number?).
 
In screenshot 3, as soon as I filtered 1.10 by Version slicer, the TotalIdByVersionAndTime in top table became wrong, and it behaved totally different compare to TotalIdByVersion (Q2: how did this happen?)

 

So far I thought the TotalId is still working, then I clicked AA in Vertical in top table. Then you can see in screenshot 4 that TotalId also became wrong. I think this is because I kept filter for [Vertical], [SubVertical], and [SubSub] for TotalId, and it is filtered by Vertical AA from the first table.

 

Q3: So how can I get the number I want in lower table? 

 

And where can I upload my Demo PowerBI report for your reference?

1.JPG3.JPG4.JPG5.JPG

 

 

 
 
1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

 

This is due to the different granularities within your one-table model and the order in which you use its fields in the visuals (see: https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/

I recommend start build a proper star-schema for your data in order to use ALLSELECTED : https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/ 
This should explain why one-table-models are a road to disaster in Power BI.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Super User
Super User

 

This is due to the different granularities within your one-table model and the order in which you use its fields in the visuals (see: https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/

I recommend start build a proper star-schema for your data in order to use ALLSELECTED : https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/ 
This should explain why one-table-models are a road to disaster in Power BI.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.