Forum Discussion
Need Help With Ranking and Counting Nonblank Rows (according to criteria)
- 7 years ago
Hi rajivraina
Sorry for replying so late.
I work with a workaround, it changea your relationships among tables, please download my pbix and see the details.
1.in "GNI" table,
create calcuated columns:
year = YEAR(GNI[Date]) GNI Rank_column = RANKX ( FILTER ( ALL ( GNI ), [year] = EARLIER ( GNI[year] ) ), [GNI per capita, Atlas method (current US$)], , DESC, DENSE ) Category_column = SWITCH ( TRUE (), 'GNI'[GNI Rank_column] < 26.5, "Advanced", AND ( 'GNI'[GNI Rank_column] >= 26.5, 'GNI'[GNI Rank_column] < 101 ), "Developing", 'GNI'[GNI Rank_column] >= 101, "Emerging", BLANK () )
merged_G= GNI[Country]&GNI[year]2.In "Debt to GDP" table, create calcuated columns
merged_d = 'Debt to GDP'[Country]&'Debt to GDP'[Year]
then create relationship between "GNI" table and "Debt to GDP" table based on [merged_G] and [merged_d]
3.In "Debt to GDP" table, create measures:
rank_value = SUM('Debt to GDP'[Government Debt to GDP]) rank_new = IF ( [rank_value] = BLANK (), BLANK (), RANKX ( FILTER ( ALLSELECTED ( GNI ), [rank_value] <> BLANK () && [Category_column] = MAX ( GNI[Category_column] ) ), [rank_value], , ASC ) ) max_percate = MAXX ( FILTER ( ALLSELECTED ( GNI ), [rank_value] <> BLANK () && [Category_column] = MAX ( GNI[Category_column] ) ), [rank_new] ) final_output = ([max_percate]-[rank_new])/[max_percate]“Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
“
Hi rajivraina
Please refer to my pbix where i create new measures in "Debt to GDP" table.
Best Regards
Maggie
- rajivraina7 years agoHelper II
Hi v-juanli-msft,
First off, thank you for taking the time to help me out.
Your solution seems to be on the right track, but measure "total" is not getting the correct values. I'm assuming this measure's goal is to count the total number of nonblank rows with data in it for that category/year. The current measure looks to output 43, but the max number of countries (according to the "Development Categories" measure) in the advanced bucket is only 26 in any given year, for Developing it is around 75 and Emerging has around 100+ countries in it. So there shouldn't be 43 I don't think?
Also, the measure "condition" and resulting measure "total" seem to not work for countries in any category other than Advanced. Not sure what's going on there.
If you could take another look that would be greatly appreciated.
Thanks,
Raj