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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Filtering out Data Conditionally

Hello! I have data similar to the table below:

 

Claim IDSurvey TypeScore
101Open9
101Closing8
101Immediate9
205Open10
205Open0
326Immediate2
458Closing6
961Immediate7
111Closing9
596Open3

 

I want to count the scores of ALL the survey responses EXCEPT those duplicate survey responses that are NOT Closing, but ONLY IF a Closing response has been submitted FOR THAT Claim ID. In other words, IF there is a Closing response AND that response is a duplicate, then count that Closing response and exclude all other responses FOR THAT Claim ID, ELSE Do Not Exclude.

 

Any help is greatly appreciated! Happy to answer clarifying questions!

1 ACCEPTED SOLUTION
speedramps
Super User
Super User

Hi bemunni

 

Click here to download example solution  

 

I am not sure if I have understood, next time please add example of the desired output to help your explanation.

 

In my attached example I added DAX measurs with comments.
The Has closing  and Has duplicate measure shoukld help you get what you need.

 

Has closing =
-- retuns 1 if claim has any closing surveys otherwise returns 0
VAR myclaimID = SELECTEDVALUE(Facts[Claim ID])
VAR myset = FILTER(ALL(Facts),Facts[Claim ID] = myclaimId && Facts[Survey Type] = "Closing")
RETURN
INT(NOT(ISEMPTY(myset)))
 
Has duplicates =
-- retuns 1 if claim has any dulicates otherwise returns 0
VAR myclaimID = SELECTEDVALUE(Facts[Claim ID])
VAR myset = FILTER(ALL(Facts),Facts[Claim ID] = myclaimId)
RETURN
IF(COUNTROWS(myset) > 1, 1, 0)
Responses =
VAR myclaimID = SELECTEDVALUE(Facts[Claim ID])
VAR myset = FILTER(ALL(Facts),Facts[Claim ID] = myclaimId)
RETURN
COUNTROWS(myset)

Answer =
--If there is a Closing response AND that response is a duplicate, then count that Closing response and exclude all other responses FOR THAT Claim ID, ELSE Do Not Exclude.

SWITCH(TRUE(),
--If there is a Closing response AND that response is a duplicate, then count that Closing response
[Has closing] = 1 && [Has duplicates], 1,
-- Else Do Not Exclude.
[Responses]
)
I am an unpaid Power BI volunteer. Please click the thumbs up if you like me trying to help you. Also click solved if I fixed your problem. One problem per ticket please. If you need to expanr or change your problem then click solved on this one and raise a new ticket. Thank you and watm regards, speedramps
 
 

 

View solution in original post

6 REPLIES 6
speedramps
Super User
Super User

I helped you, now please can you help me with kudos.

I am a unpaid Power BI volunteer.

Please click the thumbs up and Accept as Solution for taking time to help you.
Thank you 😁

 

speedramps
Super User
Super User

I am an unpaid power Bi volunteer. Please click solved to accept the solution so we get kudos. If your problem has expanded or changed then set this one to solved and raise a new ticket, because this solution does seem to answer the original question. Also try include example of the imput and desired output with a decsription so we kneo what you need. Many thanks.

speedramps
Super User
Super User

Hi bemunni

 

Click here to download example solution  

 

I am not sure if I have understood, next time please add example of the desired output to help your explanation.

 

In my attached example I added DAX measurs with comments.
The Has closing  and Has duplicate measure shoukld help you get what you need.

 

Has closing =
-- retuns 1 if claim has any closing surveys otherwise returns 0
VAR myclaimID = SELECTEDVALUE(Facts[Claim ID])
VAR myset = FILTER(ALL(Facts),Facts[Claim ID] = myclaimId && Facts[Survey Type] = "Closing")
RETURN
INT(NOT(ISEMPTY(myset)))
 
Has duplicates =
-- retuns 1 if claim has any dulicates otherwise returns 0
VAR myclaimID = SELECTEDVALUE(Facts[Claim ID])
VAR myset = FILTER(ALL(Facts),Facts[Claim ID] = myclaimId)
RETURN
IF(COUNTROWS(myset) > 1, 1, 0)
Responses =
VAR myclaimID = SELECTEDVALUE(Facts[Claim ID])
VAR myset = FILTER(ALL(Facts),Facts[Claim ID] = myclaimId)
RETURN
COUNTROWS(myset)

Answer =
--If there is a Closing response AND that response is a duplicate, then count that Closing response and exclude all other responses FOR THAT Claim ID, ELSE Do Not Exclude.

SWITCH(TRUE(),
--If there is a Closing response AND that response is a duplicate, then count that Closing response
[Has closing] = 1 && [Has duplicates], 1,
-- Else Do Not Exclude.
[Responses]
)
I am an unpaid Power BI volunteer. Please click the thumbs up if you like me trying to help you. Also click solved if I fixed your problem. One problem per ticket please. If you need to expanr or change your problem then click solved on this one and raise a new ticket. Thank you and watm regards, speedramps
 
 

 

Anonymous
Not applicable

The result is to pass the count of the non-excluded scores (by Type, i.e. 8-10 = Promoter, 6-7 = Passive, Else Detractor) into another formula that calculates a net promoter score. So, it's actually Count of Score Type EXCLUDING those Score Types I want exluded as previously mentioned. The table should actually look more like this:

Claim IDSurvey TypeScoreScore Type
101Open9Promoter
101Closing8Promoter
101Immediate9Promoter
205Open10Promoter
205Open0Detractor
326Immediate2Detractor
458Closing6Passive
961Immediate7Passive
111Closing9Promoter
596Open3Detractor

 

Although, I may have not understood clearly your need becuase both your explanations are bit confusing evn with much effort you put to explain. Based on what I assumed, pls confirm if you need to see something like this as below and then filter the count column which are >1 and Promoter, i.e. claim ID 101 your case:

 

Capture.PNG

HotChilli
Super User
Super User

What's the desired result from the provided data?

It will be helpful if you could explain the result according to the algorithm you describe above.

And, when you say count, do you mean count, or sum ?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.