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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
RandVac
Frequent Visitor

What's the difference between these 2 queries?

A small data model with two tables <Dfact> <Ddim>

<Ddim>[SubCategory] (1) --- (*) <Dfact>[SubCategory]

RandVac_0-1702188352900.pngRandVac_1-1702188372337.png

The first query returns 3. 

RandVac_3-1702188441173.png

 

Whereas the second query returns 1.

RandVac_2-1702188435170.png

 

<Dfact>

IDSubCategory
1SC1
2SC1
3SC2
4SC2
5SC3
6SC3

<Ddim>

CategorySubCategory
C1SC1
C1SC2
C2SC3
C2SC4
C3SC5
EVALUATE
CALCULATETABLE ( 
	{ COUNTROWS ( Ddim ) }, 
	Dfact, 
	Dfact[SubCategory] = "SC1" 
)

EVALUATE
SUMMARIZECOLUMNS (
    Dfact,
    FILTER ( ALL ( Dfact[SubCategory] ), Dfact[SubCategory] = "SC1" ),
    "count", COUNTROWS ( Ddim )
)

 

What's the difference between the 2 quries?

Thanks in advance.

 

 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

This is what happens under the hood for query 1,

ThxAlot_1-1702211709608.png

 

For any CALCULATE() / CALCULATETABLE(), DAX engine evaluates all filter arguments ( 1.expanded table and 2.predicate in your case ) independently from each other before final evaluation.

 

More specifically,

1.expanded table

filters Ddim via [related C] and [related SC] (data lineage kept)

ThxAlot_2-1702211884287.png

2.predicate

doesn't propagate the filtering to Ddim due to 1:* direction constraint by default.

 

An alternative to query 2 is

ThxAlot_3-1702212514150.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

4 REPLIES 4
ThxAlot
Super User
Super User

This is what happens under the hood for query 1,

ThxAlot_1-1702211709608.png

 

For any CALCULATE() / CALCULATETABLE(), DAX engine evaluates all filter arguments ( 1.expanded table and 2.predicate in your case ) independently from each other before final evaluation.

 

More specifically,

1.expanded table

filters Ddim via [related C] and [related SC] (data lineage kept)

ThxAlot_2-1702211884287.png

2.predicate

doesn't propagate the filtering to Ddim due to 1:* direction constraint by default.

 

An alternative to query 2 is

ThxAlot_3-1702212514150.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Many thanks!

Now I know what I misunderstood about the CALCULATE.

I mistakenly thought CALCULATE merges the filter arguments by intersection before applying to the data model as below:

RandVac_0-1702220067546.png

The arguments are evaluated independently from each other in the CALCULATE, and they filter the corresponding columns separately before final evaluation.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure what is your desired outcome, but regarding the first one,

it shows the same result if it is written like below.

Jihwan_Kim_0-1702195987531.png

 

And, having the condition like the below on many side of the relationship

Dfact[SubCategory] = "SC1"

does not influence on counting rows in one side of the relationship.

 

 

I assume you want to see this result = 1, and please try something like below.

 

RELATEDTABLE function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_1-1702196068623.png

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Thank you!

I was wondering how CALCULATE merges the filter arguments and yes I was confused why it's not 1.

I mistakenly thought CALCULATE would apply the filter Dfact[SubCategory] = "SC1" to the first filter argument <Dfact>. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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