Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
prady2581
Helper I
Helper I

NPS CALCULATION QUERY ON FILTER CONTEXT

Formula used for nps calcuation is as below, want to check whether it is appropriate to use ALL/ALLSELECTED/ALLexcept in the end. In the power bit report i have slicers by region, department, etc and i use this measure in table matrix view. Im not able to visual what is the impact of making use of this above function and without it. Appreciate if any explaination on this aspect in terms of actual use case.

 

NPSScore = var Promotercount = [Promoter count]
var Passivecount = [Passive count]
var Detractorcount = [Detractor count]
var Nu = Promotercount - Detractorcount
var Dn = [Total surveys]
Var Result = DIVIDE( Nu, Dn )*100
Return
CALCULATE(Result, REMOVEFILTERS('Raw data')
)
5 REPLIES 5
DanielGarcia
Advocate I
Advocate I

Good morning, man!

 

So, maybe this can help you with examples:

https://community.powerbi.com/t5/Community-Blog/The-ALL-ALLSELECTED-amp-ALLEXCEPT-Code/ba-p/1019987

 

But basically this functions make filters in another tables that have relation with the measure that you create.

 

Example: Do you need to calculate the NPS of this year, but in the visual do you have one slicer that filter a mouth… For ignoring this slicer and keep filtering the NPS of this year, you can use the function “REMOVEFILTER” of the table calendar, with this you are “ignoring” the slicer on the mouth.

Thanks Daniel. The matrix table has rows by client name, column fieds has month fiscal-year it should consider the filter context row and column and any of the defaul context from slicers. Do I need to use allselected in this case. 

Depends, if you want that the slicers change this measure, you don't need to use this functions… Your formula could be like that:

 
NPSScore = var Promotercount = [Promoter count]
var Passivecount = [Passive count]
var Detractorcount = [Detractor count]
var Nu = Promotercount - Detractorcount
var Dn = [Total surveys]
Var Result = DIVIDENuDn )*100
Return Result

But if you need that the measure don't change with the slices, yes, use the function allselected
 
Try the two options and validate the results.
 

Thanks daniel, I;ll check both options and see it matches my requirement.

You're welcome friend, anything, I'm at your disposal.

If I have a positive result, could you mark this question as resolved?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.