Forum Discussion
Add percentiles using a calculated measure
What's wrong with PERCENTILEX.INC - DAX Guide?
By the way, it's still not clear what you mean by a "percentile measure." A percentile is a 2-variable function , f(x: Multiset(R), y: R) -> R , that depends on: (x) the data set you give it and (y) the threshold you define between 0 and 1. So I'm still unable to determine exactly what you really want. Which exactly percentile are you talking about? For instance, if you want the 25th percentile (the 1st quartile) for cities based on some [M]easure calculated for the cities, then you'd write:
percentilex.inc(
summarize(
FactTable,
Cities[CityID]
),
[M],
0.25
)
If you want the same but just for countries, then you'd need to change Cities[CityID] to some kind of Country[CountryID]. If you want to have percentiles for different levels of a hierarchy, then you'll have to create a specific measure for this very hierarchy using ISINSCOPE and a proper formula for each level...
I also tried to write the measure as you suggested to try it out, but only got the same result as my employmentratio :
I both tried to use the measure, and declare them in variables like in the screen shot
- Anonymous4 years agoNot applicable
You can't use variables the way you do. Variables in DAX are in fact static. Once calculated, they never change, so your attempt to use a variable in the function the way you try to is futile.
- Anonymous4 years agoNot applicable
Ultimately, all I am trying to do is have the corresponding percentile for each row by country and then by city. I am just trying things out and suggesting ideas to get there.
I would like to avoid calculated columns because to my understanding they are more ressource intensive (the column would be on a large table) especially since I have to make a dozen of percentil measure with data on the same table (I have a dozen categories)
- Anonymous4 years agoNot applicable
OK, but it's still not clear. Let's consider this scenario. You put some cities into a visual (say, table) and have a slicer that only shows cities in 2 different countries. Something like this (let's assume, for the time being, that the names of the cities are unique across the whole data set):
Table 1.
Country | City | EmploymentRatio
--------------------------
US | A | 0.20
US | B | 0.40
US | C | 0.80
UK | D | 0.10
UK | E | 0.50
UK | F | 0.80
Note that I added the column Country but it's only for technical reasons; treat it as if it were not there. In fact the table shows only cities while the countries have been selected somewhere in a slicer put on the canvas.
Let's assume further that there is another slicer somewhere there that has filtered the following cities out of the visual:
US | A1 | 0.15
US | B1 | 0.45
US | C1 | 0.90
UK | D1 | 0.20
UK | E1 | 0.60
UK | F1 | 0.90
Question: What do you expect to see in the rows of the first visual if you put your mentioned measure in there?