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
Kumshan450
Helper III
Helper III

DAX function to replicate Excel Index Match and Count if Function

I have address data. I want to find whether certain keyword in address field matches with the list mentioned in the negative Area. 

I applied below formula in excel file: =IFERROR(INDEX(Sheet2!$C$2:$C$9,MATCH(1,COUNTIF(D2,"*? "&Sheet2!$C$2:$C$9&"*?"&Sheet2!$D$2:$D$9),0),0),"").

In excel file it takes time as there are more than 7 million rows of data.

So my perception is that DAX formula would be faster and formula would be automated. I have applied the dax formula but not getting the correct result.  Please find herewith the link for the sample file. 

Excel File

https://drive.google.com/file/d/14MbimcuQOsCb7I1FVBXW_NEKS_rpoWDr/view?usp=sharing

Power BI file

https://drive.google.com/file/d/1g_dfN-qm9G_D7WD3OQv_q2hnQingzPc-/view?usp=sharing

If you check the results of the Negative Area column in the excel file and Power BI file, the result of the excel file is correct. 

Is there any method to speed up the lookup operation in dax so that it does not take more time in the evaluation. 

2 ACCEPTED SOLUTIONS

Your DAX attempt is missing the PINCODE part. 

 

I think this should work, but not sure it's the most efficient solution: 

NegativeArea = CALCULATE(
FIRSTNONBLANK(NegativeArea[Address],NegativeArea[Address]),
FILTER (
NegativeArea,
CONTAINSSTRING(AddressData[Address],NegativeArea[Address]) && CONTAINSSTRING(AddressData[Address], NegativeArea[PINCode])
))

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Why are we searching for columns C and D appearing in the NeagtiveArea worksheet in column D of the Addressdata worksheet?  Why not search only for column C appearing in the NeagtiveArea worksheet in column D of the Addressdata worksheet?  Wouldn't that be enough?


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

Hi,

 

The logic is area+Pin code both should match. 

For Eg, if you check Vishal Nagar as Negative Area. 

In the address data worksheet, there are two loan accounts where the address contains Vishal Nagar. If I apply only by column c then the second loan will also get matched up which I don't want as PIN code is different. So PIN code is mapping is required in the formula. 

Loan NoStateBranchAddressNegativeArea
655RajasthanJaipurGali No 5 Janta Dal Colony Vishal Nagar Vishal Market Jaipur 511202Vishal Nagar
329MaharashtraPuneSector 08 Vishal Nagar Vishal Market Jaipur 411252 

 

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

Can you explain the goal in business sense, not just Excel formula? Looks like your DAX formula doesn't currently account for the PIN, does the Address[Address] always have the 6 digit PIN at the end? If so you can split those columns or use that to get the right answer eventually. Lookup, search, etc are still not exactly efficient in DAX, so if you can describe further the why and the goal the community might have some better solutions for you. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

The goal is to find whether my address data contains any Negative area with PINcode Keyword. This is used for analyzing total business and the number of loans booked in negative areas. 

Yes, all addresses end with PIN code. 

Your DAX attempt is missing the PINCODE part. 

 

I think this should work, but not sure it's the most efficient solution: 

NegativeArea = CALCULATE(
FIRSTNONBLANK(NegativeArea[Address],NegativeArea[Address]),
FILTER (
NegativeArea,
CONTAINSSTRING(AddressData[Address],NegativeArea[Address]) && CONTAINSSTRING(AddressData[Address], NegativeArea[PINCode])
))

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.