March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
Hi everyone!
I have an issue which I believe is related to my lack of understanding on how custom DAX columns interact with filters.
So my set of data contains lots of IDs and some associated attributes for those IDs ( This is a result of an unpivot operation as you can see in the picture, the original data had one ID per record and an "Attribute" column with a list/string of attributes and I converted it to multiple rows ).
This is how the data looks like:
The first thing I wanted is to know number of attributes each ID had ( considering now that the table is unpivoted there are many rows with the same ID). For this task this DAX code for the column seems to be doing great:
This also seems to work , as if I count the total of Attributes and the total of distinct IDs and proceed with the division it is correct. The issue comes when trying to use other category tables that I have and stablish some filters, in this case the DAX column doesnt change at all which of course results in the average being incorrect.
For instance if I have a slicer and select only "Text1 , 2 and 3" for Attributes, the number of Attributes per ID for ID 0000998877.1 remains at 8 and ,of course, the Average function gives an incorrect result.
I have tried using some ALL and ALL except in the filter for the DAX column but I have been unsuccessful.
I am aware I could just use a measure count(Attributecode) / distinctcount(ID) and would achieve this result and interact with my slicers but I was wondering if I could manage that result with DAX, I am trying to learn it and want to get familiar with it.
What am I missing for this column to behave as expect?(Or perhaps I am overcomplicating the data model by trying to use custom DAX column for that?)
Many thanks in advance!
Solved! Go to Solution.
@AutoJL , A calculated column or table does no interact with the slicer/ filter. They are static.
So you might need work with measures
example
Number of Attributes per ID = CALCULATE(COUNT([ID]),FILTER(allselected(AttributesTable),[ID]=max([ID])))
refer if needed Power BI Beginners!
: https://www.youtube.com/watch?v=cN8AO3_vmlY
@AutoJL , A calculated column or table does no interact with the slicer/ filter. They are static.
So you might need work with measures
example
Number of Attributes per ID = CALCULATE(COUNT([ID]),FILTER(allselected(AttributesTable),[ID]=max([ID])))
refer if needed Power BI Beginners!
: https://www.youtube.com/watch?v=cN8AO3_vmlY
Hi @amitchandak !
Many thanks for the help. That measure indeed did the same thing as the calculated column! I was not able to use it to calculate the average though. I any case I realized that I could do it using simple measures and then making use of the proper relations/filtering for the attributes.
Bookmarked your video and channel!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
91 | |
89 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
72 | |
68 |