79733947

Date: 2025-08-13 06:36:01
Score: 1.5
Natty:
Report link

Solution based on python:

let
    BufferedTAB1 = Table.Buffer(TAB1),
    BufferedTAB2 = Table.Buffer(TAB2),

    PythonStep = Python.Execute(
"
import pandas as pd
import re

# Import data from Power Query
tab1 = dataset1.copy()
tab2 = dataset2.copy()

results = pd.DataFrame()

# Cross join 
tab1['key'] = 1
tab2['key'] = 1
for _, row1 in tab1.iterrows():

    row1_df = pd.DataFrame([row1])
    merged = pd.merge(row1_df, tab2, on='key').drop('key', axis=1)

    mask = merged.apply(lambda row: bool(re.match(str(row['MASK']), str(row['ACCOUNT']))), axis=1)
    filtered = merged[mask]
    results = pd.concat([results, filtered], ignore_index=True)

",
        [
            dataset1 = BufferedTAB1,
            dataset2 = BufferedTAB2
        ]
    ),

    TAB3 = PythonStep{[Name="results"]}[Value],
    Result = Table.SelectColumns(TAB3, {"GR", "PRODUCT", "ACCOUNT"})
in
    Result

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Jacek