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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

HELP! DAX logic - cant figure out.

I have a table designed vertically for dimensions.

 

Product Table - 

Product DimensionProduct Category
AFruit
BVegetable
CDiary

 

SomePrimaryID

Product Dimension

Value

1A1
2A2
3B3
1B4
2B5
1C6
3C5

 

Now, I have a slicer on Product Dimension.

 

A

B

C

 

When user selects A and C together, I want magical DAX to do the following -

 

For A, the following data belongs to Product A as per table above.

SomePrimaryIDProduct DimensionValue
1A1
2A2

 

For C, the following data belongs to Product C as per table above.

SomePrimaryIDProduct DimensionValue
1C6
3C5

 

Now, I want only unique primary IDs to be considered between A and C to get SUM(Value).

Looking at above - unique primary ID between A and C is 1.

 

SomePrimaryIDProduct DimensionValue
1

A

1
1C6

 

Therefore, Product Dimension A & C selected in the slicer should return the following in -

 

Product DimensionValue
A7
Total7

 

DAX I tried: 

 

VAR ProdFruits =

CalculateTable (Values(SomePrimaryID), Filter(Products, Product = "Fruit")

Var ProdDiary =

CalculateTable (Values(SomePrimaryID), Filter(Products, Product = "Diary")

Var Intersection =

NATURALINNERJOIN(ProdFruits, ProdDiary)

 

RETURN

 

CALCULATE (SUMX(Intersection, SUM(Value)), Product Dimension = "Fruit")

 

For some reason, I am not able to figure out where am i going wrong and why its not working!!

 

I hope I was clear enough in explaining the problem examples above. Thanks in advance.

 

Link to sample PBIX file - SAMPLE PBIX FILE 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks Ricardo, I tried the DAX above and doesnt seem to give me desired output :(.

 

When I replaced the measure with your suggested DAX, I get the following -

 

Product DimensionCalculatedValue
A1
C6
Total7

 

However, what i want to see is the following -

 

Product DimensionCalculatedValue
A7
C7
Total7

 

I believe it is very close to the solution, not sure what other manipulations in DAX syntax can be done to acheive above?

 

Your help is much appreciated.

 

Thanks.

View solution in original post

3 REPLIES 3
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this code:

CalculatedValue =
VAR _min = CALCULATE(MIN(ProductFactTable[SomePrimaryID]); ALLEXCEPT(ProductFactTable; ProductFactTable[Product Dimension]))
RETURN CALCULATE(SUM(ProductFactTable[Value]); FILTER(ALLEXCEPT(ProductFactTable; Products[Product Dimension]); ProductFactTable[SomePrimaryID] = _min))
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

Thanks Ricardo, I tried the DAX above and doesnt seem to give me desired output :(.

 

When I replaced the measure with your suggested DAX, I get the following -

 

Product DimensionCalculatedValue
A1
C6
Total7

 

However, what i want to see is the following -

 

Product DimensionCalculatedValue
A7
C7
Total7

 

I believe it is very close to the solution, not sure what other manipulations in DAX syntax can be done to acheive above?

 

Your help is much appreciated.

 

Thanks.

Anonymous
Not applicable

Find the solution attached. But note that measures where ALLSELECTED is used should never be used in ITERATORS. This is of utmost importance. If you ignore this rule, your measures will be WRONG. Simply. And you won't be able to understand why. You'll need to read a lot about how ALLSELECTED works and there's a lot to understand.

 

Best

D

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.