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.
Sorry if this is a simple question, I am still learning DAX. I am trying to do a filter, and the logic seems to be failing. I have a measure that under the current slicer calculates to [w_Selected] = "4th". I want to use that result to filter out all the countries that have w_quartile = "4th". Under my two commented out calcs, they sell to all be equal. [w_Selected] = "4th" returns True, and the number of rows I get from my filter when I filter on "4th" returns 29. However, when I filter on [w_Selected], I only get one (where I am expecting 29 again. Can anyone help point out where I am going wrong? Thanks a lot for help
Measure =
//EXACT("4th", [w_Selected]) returns True
// COUNTROWS(FILTER(all(country_rankings), country_rankings[w_quartile]="4th")) returns 29
// COUNTROWS(FILTER(all(country_rankings), country_rankings[w_quartile]=[w_Selected])) returns 1
Solved! Go to Solution.
Hi @Anonymous
try
count_filtered =
var _w_Selected = [w_selected]
RETURN
CALCULATE(COUNTROWS(country_ranks), ALL(country_ranks), country_ranks[w_quartiles]=_w_Selected)
@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
I made a simple sample pbix at the following link: https://filebin.net/499kgity07ereogt
The idea is that I have a slicer for countryID, I want to use that selected countryID to lookup it's w_quartile, and then filter the other table to only show the countries that share the same quartile. In this pbix example, I have countryID = 6 selected. The first measure shows correctly that country 6 has w_quartile = 4th. The second measure confirms the selection is equal to the text string "4th" (just making sure..). The third measure then tries to filter the country_info table to show only the projects that have w_quartile = 4th, but when I count the rows that come out of the filter I get 11 when I am expecting 4 based on the data (countryIDs = 4, 5, 6, 11).
Hi , @Anonymous
As mentioned by @az38 , try to store [w_selected]with variable "a" in advance.
Measure2_"selected" =
var a=[w_selected]
return COUNTROWS(FILTER(ALL(country_ranks), country_ranks[w_quartiles]=a))
Best Regards,
Community Support Team _ Eason
Hi @Anonymous
try
count_filtered =
var _w_Selected = [w_selected]
RETURN
CALCULATE(COUNTROWS(country_ranks), ALL(country_ranks), country_ranks[w_quartiles]=_w_Selected)
Thanks both of you, this worked!
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 |
---|---|
96 | |
95 | |
82 | |
71 | |
64 |
User | Count |
---|---|
116 | |
106 | |
94 | |
79 | |
72 |