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
dilumd
Solution Supplier
Solution Supplier

DAX help

Hi All,

 

I have below simple table,

DateCategory1Category2Qty
1/1/2018AQ2
1/2/2018AS3
1/3/2018BR4
1/4/2018BT6
1/5/2018CY4
2/1/2018AQ9

 

I want to calculate total quantity column which doesn't change based on the category2 filter. I wrote a function as follows which returns the expected results. But when I apply filter to a date column this behavior doesn’t persist (check below screenshots).

 

Function,

Quantity_M = CALCULATE(SUM(Test_Table[Qty]),ALLEXCEPT(Test_Table,Test_Table[Date],Test_Table[Category1]))

Without any filterWithout any filterwhen i click on category2 "Quantity_M" doesn't change (which is what i want)when i click on category2 "Quantity_M" doesn't change (which is what i want)when i apply a filter on dateswhen i apply a filter on datesafter the date filter when i click on "category2" (above behavior changes and "allexcept" function doesn't apply after that.after the date filter when i click on "category2" (above behavior changes and "allexcept" function doesn't apply after that.

Can some help me to understand this and tell me how to get it right please.

1 ACCEPTED SOLUTION

Hey @dilumd,

 

understand! With your current data model (just one table) this will become a nightmare, for this reason I recommend to adjust your datamodel to this

image.png

 

I set the Cross filter direction between table1 and "Category2", because category2 seems less important to me than category1, maybe I err. But this allows that the content of the slicer for "Category 2" based on the coresponding table, namely "Category 2" reacts to selections of the slicer Category 1
Category1 --> Table1 <--> Category2

 
I created the tables Category 1 and Category 2, using these simple DAX statemens, e.g. Category 1:

Category 1 = 
VALUES(Table1[Category1]) 

Then I created a measure like so:

Quantity_T = 
CALCULATE(
    SUM(Table1[Qty])
    ,ALL('Category 2'[Category2])
)

This results to this report - please be aware that the content of the Category slicers is coming from the category tables:

image.png

 

Hopefully this is what you are looking for, or at least gives an idea, of course the new measure returns 19, if nothing from Category 1 is selected 🙂

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

10 REPLIES 10

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.