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

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.

Reply
Anonymous
Not applicable

A knotty problem to return a value based on multiple criteria

Dear hive mind! 

 

Some background first...

 

I have a table with >200k rows - extract below;

 

Cust IDCust TypeCust PostcodeParent IDInvoice IDInvoice Parent IDValid?
377945BookingWC7B 6NH3779451161427377945 
1089241BookingCV75 ONR3779451165160377945 
1093354BookingWC7B 6NH3779451166118377945 
1093661BookingYO5 7PR3779451166156377945 
1122507BookingWC7B 6NH3779451185210377945 
1134558BookingYO5 7PR37794511568971091197Error
1135019BookingKT55 5NB37794511568971091197Error
1135665BookingNE4 7YH37794511568971091197Error
1135669BookingMK9 5NS37794511568971091197Error
1139664BookingYO5 7PR3779451193803377945 
1161427InvoiceWC7B 6NH3779451161427377945 
1165160InvoiceCV75 ONR3779451165160377945 
1166118InvoiceWC7B 6NH3779451166118377945 
1166156InvoiceYO5 7PR3779451166156377945 
1185210InvoiceWC7B 6NH3779451185210377945 

 

Each row pertains to a Customer record, which can either be an Invoice account or a Booking account.

 

Every Customer entity has a Parent ID, making them part of the same family.

 

Every Customer also has an Invoice ID, and each Invoice ID exists in the table as a separate row in the table.

 

The issue is that some of these Invoice accounts have a different Parent ID to the original Customer record, which makes them invalid, i.e. the Invoice account actually belongs to another family.

 

I've already written custom DAX ("Invoice Parent ID" column) to expose the Parent ID for each Invoice account, and another column which confirms if the Customer Parent ID differs from the associated Invoice Parent ID ("Valid?" column).

 

And so, to my problem.....!

 

I need to be able to identify if a Customer marked as "Error" has an alternative Invoice account within the same family with the same postcode,

 

In the example above the red text error row shares a postcode with the blue text non-error row, which is an Invoice account.

 

Whilst the green rows share a postcode with the red error row, and are not error rows themselves, they are invalid as they are Booking accounts, not Invoice accounts.

 

For every error row, if a single Invoice ID can be found, matching the above criteria, then I'd like to return this ID in a new column.  If multiple valid alternatives exist, I'd like to return "Multiple" in the same column, and if no valid alternatives exist I'd like to return "None".

 

I'm convinced this must be doable....but sadly it's beyond my level of knowledge to figure out the best approach, so any suggestions would be greatfully received!!

 

Many thanks (and well done if you've managed to stick with me this far! haha)

1 REPLY 1
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

It's a challenge to sovle it. I will take some time to think about it.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.