Forum Discussion

cingram11's avatar
cingram11
Regular Visitor
1 year ago
Solved

Matching Logic Report

I want to create a report that would show, for example, Item #s that are purchased by both Restaurant A and Restaurant B. How would I implement this? I currently have a table, in table view, with a c...
  • v-hjannapu's avatar
    v-hjannapu
    1 year ago

    Hi cingram11,

    Yes, you can do this without creating a new table. You just need to add a calculated column in your existing table that checks if the item is bought by both Restaurant A and B.
    Dax you can use :

    CommonItemFlag = 
    VAR TargetBrands = {"Restaurant A", "Restaurant B"}
    VAR BrandCount =
        CALCULATE (
            DISTINCTCOUNT(SalesData[Brand]),
            FILTER (
                SalesData,
                SalesData[Item #] = EARLIER(SalesData[Item #]) &&
                SalesData[Brand] IN TargetBrands
            )
        )
    RETURN
    IF(BrandCount = 2, 1, 0)
    

    This approach will return a value of 1 for items that are shared between the two restaurants. You can then filter this column in your report to display only these common items.
    I hope this information is helpful.

    If the answer is helpful, please click "Accept Answer" and feel free to give a Kudos, so others can benefit as well.
    Best Regards,
    Harshitha.