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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Deleting Multiple Rows for multiple conditions

Hello, I am 

 

Probelm:  As you can see, a Account Number can have multiple Status. I am trying to write a query where the query looks for the first account number and checks if it has a "SEE Status" of "Applicable" if it has then I want it to delete the row for the account number with Not Applicable "SEE Status". Now I want it to move to the next Account Number and Look for the same, if it does not have a "Applicable" Status then I want it to retain just one row from the "Not Applicable"  "SEE Status" and delete the other rows and so on.

Problem:

Account Number            SEE Status

10                                    Not Applicable

10                                    Applicale

11                                    Not Applicable    

 

Desired Out put:

10                                    Applicale

11                                    Not Applicable    

 

Please Help!

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Based on your limited information, this DAX formula works

if(HASONEVALUE(Data[Account Number]),if(DISTINCTCOUNT(Data[SEE Status])>1,"Applicable",VALUES(Data[SEE Status])),BLANK())

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Based on your limited information, this DAX formula works

if(HASONEVALUE(Data[Account Number]),if(DISTINCTCOUNT(Data[SEE Status])>1,"Applicable",VALUES(Data[SEE Status])),BLANK())

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
MFelix
Super User
Super User

Hi @Anonymous ,

 

I'm assuming based on your model that you only have two SSE status (Applicable / Not Applicable), if that is true on the query editor do a group by with the SSE Status Minimum value, if you have more than one column on your table add them on your group by option.

 

Check M Code below:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lHyyy9RcCwoyMlMTkzKSVWK1YGKo4sZ4lBrhEccXcwYTSwWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Account Number" = _t, #"SEE Status" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Account Number", Int64.Type}, {"SEE Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Account Number"}, {{"SEE Status", each List.Min([SEE Status]), type text}})
in
    #"Grouped Rows"

On my example I have added a couple more accounts in order to test values that only have applicable.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

CAN YPU PLEASE SHARE YOUR EXCEL SHEET WHICH HAS POWER QUERY IN IT?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors