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.
Hi,
I have used the below measures in card to identify the top 1 to 5 project name.
However, I wish to add an if statement to return a 'Blank' as an output on the card if there is no 2nd /3rd/4th of 5th project. Currently, this measure is returning the same project name between 1 to 5 even if there are only one project. It returns blank if there is no project and it works fine if there are more than 5 projects to identify the top 1 to 5.
With the table below when I select the country like Australia, I do get the top 5 project name (Alpha, Gamma, Apollo, Narellan, Aquaone) based on their project priority score.
However, for Fiji, I get a return of Beta, Delta, Bluedog, Bluedog ( i wish to proceed with an output of Beta, Delta, Bluedog, Blank) and for New Zealand, it returns Vitafresh, Vitafresh, Vitafresh, Vitafresh, Vitafresh ( i wish to proceed with an output Vitafresh, Blank, Blank, Blank, Blank)
Project Name | Project Priority Score | Country |
Project Alpha | 1 | Australia |
Project Beta | 2 | Fiji |
Project Gamma | 3 | Australia |
Project Delta | 4 | Fiji |
Project Apollo | 5 | Australia |
Project Bluedog | 6 | Fiji |
Project Narellan | 7 | Australia |
Project Vitafresh | 8 | New Zealand |
Project Aquaone | 9 | Australia |
I am not sure if an if statement is the right way to go. I am happy to explorer other option as well to make this work.
Appreciate your help on this.
Solved! Go to Solution.
The below seems to work fine
Test 4th Ranked Project = if(
CALCULATE(SELECTEDVALUE('PowerBi Data Export'[Project Name]),TOPN(1,TOPN(2,TOPN(3,TOPN(4,ALLSELECTED('PowerBi Data Export'),'PowerBi Data Export'[Project Priority Score], ASC)))))=
CALCULATE(SELECTEDVALUE('PowerBi Data Export'[Project Name]),TOPN(1,TOPN(2,TOPN(3,ALLSELECTED('PowerBi Data Export'),'PowerBi Data Export'[Project Priority Score], ASC))))), "Blank",
"CALCULATE(SELECTEDVALUE('PowerBi Data Export'[Project Name]),TOPN(1,TOPN(2,TOPN(3,TOPN(4,ALLSELECTED('PowerBi Data Export'),'PowerBi Data Export'[Project Priority Score], ASC))))))
The below seems to work fine
Test 4th Ranked Project = if(
CALCULATE(SELECTEDVALUE('PowerBi Data Export'[Project Name]),TOPN(1,TOPN(2,TOPN(3,TOPN(4,ALLSELECTED('PowerBi Data Export'),'PowerBi Data Export'[Project Priority Score], ASC)))))=
CALCULATE(SELECTEDVALUE('PowerBi Data Export'[Project Name]),TOPN(1,TOPN(2,TOPN(3,ALLSELECTED('PowerBi Data Export'),'PowerBi Data Export'[Project Priority Score], ASC))))), "Blank",
"CALCULATE(SELECTEDVALUE('PowerBi Data Export'[Project Name]),TOPN(1,TOPN(2,TOPN(3,TOPN(4,ALLSELECTED('PowerBi Data Export'),'PowerBi Data Export'[Project Priority Score], ASC))))))
Refer
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://www.youtube.com/watch?v=wKfPS1yZfE0
how to use visual level filter the top nth -https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
Thanks Amit but I couldn't find any relevance on what I am trying to achieve here.
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 |
---|---|
106 | |
93 | |
75 | |
62 | |
50 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |