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.
What I am trying to accomplish:
I want to do a percent of parent calculation.
We are counting the number of patients that are in a specific Line of Therapy, in a specific date range, for a given division. I want to know what percent of those patients are on a specific drug.
The numerator is the count of patients that are in a specific Line of Therapy, in a specific date range, for a given division, who are taking a specific drug.
The denominator is the count of patients that are in a specific Line of Therapy, in a specific date range, for a given division. We want to ignore the drug here.
What is happening:
When I select a specific drug the denominator of this measure is being sliced, but it should not be.
The measure for the denominator is as follows:
CALCULATE (
DISTINCTCOUNT fctLineOfTherapy[ProjectCombinedDivisionMpi] ),
ALLEXCEPT (
fctLineOfTherapy,
fctLineOfTherapy[LotName],
fctLineOfTherapy[LOTStartDate],
DivisionMask[DivisionMask],
ProjectDefinition
)
)
The visuals:
Before selecting a drug
After Selecting a drug:
Notice that the blue section Above has gone from 11% to 23%. This is caused because the denominator changed from 1,173 to 571. The numerator is fine.
The Data:
I am not able to provide real data, but here is some faked data to give an idea what we are working with. I have used a hash to hide some of the data as it contains PHI and cannot be shared.
The data model:
Thanks Darlove,
You have confirmed my suspicion that the modeling is causing us issues. Do you have any suggested reading that may help me correct this?
The best course I've personally been through is the one on www.sqlbi.com (the one on creating models). Yes, it's not free but you'll not find anything better. All my knowledge comes from those two guys - Alberto Ferrari and Marco Russo - and they are the creators.
Also, when you want to remove all filters from a table, you just do:
calculate( [Measure], ALL( TheTable )).
So, if you want to remove the filter on a Drug dimension, you should use the above where TheTable = Drug.
Also, bear in mind that ALLEXCEPT does nothing if there is no explicit filter on the columns enumerated under it. This happens very often with fact tables. If they are sliced by dimensions, then there are no explicit filters on the columns. A good design is one where the fact table's columns are all hidden (can't be used to slice), only measures defined in the table are exposed. All slicing must be done through dimensions. Also, 99% of the time dimensions are connected to facts through 1:* with one-way filtering from the dimension to the fact table. There are very specific scenarios where cross-filtering should be used. Using it as a habit will almost immediately lead to creating numbers that'll be hard to understand and simply will be incorrect.
Best
D
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
36 | |
33 | |
18 | |
18 |