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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
AwaisAnwar
Frequent Visitor

Getting not matched result of two tables column

Hi, I am trying to calculate the number of customer who buys milk only. I have gone through different posts and this solution i got. But when i apply this error is "error single value was expected where as table of multiple values was suppliued"
 
Customerbuyingmilkthisweek =
 VAR Customerlistmilk = CALCULATETABLE(VALUES('Distinctcustomer'[LocationReference]),'Weekly Data'[Weeknum] = MAX('Weekly Data'[Weeknum]),'Weekly Data'[Product Catagory1_3] = "Milk")
 VAR Customerlistother = CALCULATETABLE(VALUES('Distinctcustomer'[LocationReference]),'Weekly Data'[Weeknum] = MAX('Weekly Data'[Weeknum]),'Weekly Data'[Product Catagory1_3] in {"Bread","Groceries","Creams"})

        return
    COUNTROWS(FILTER(Customerlistmilk,Customerlistmilk  Not in (Customerlistother)))
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Try it using EXCEPT

Customerbuyingmilkthisweek =
VAR Customerlistmilk =
    CALCULATETABLE (
        VALUES ( 'Distinctcustomer'[LocationReference] ),
        'Weekly Data'[Weeknum] = MAX ( 'Weekly Data'[Weeknum] ),
        'Weekly Data'[Product Catagory1_3] = "Milk"
    )
VAR Customerlistother =
    CALCULATETABLE (
        VALUES ( 'Distinctcustomer'[LocationReference] ),
        'Weekly Data'[Weeknum] = MAX ( 'Weekly Data'[Weeknum] ),
        'Weekly Data'[Product Catagory1_3] IN { "Bread", "Groceries", "Creams" }
    )
VAR CustomerMilkOnly =
    EXCEPT ( Customerlistmilk, Customerlistother )
RETURN
    COUNTROWS ( CustomerMilkOnly )

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

I think the problem with your original was in the NOT IN section.  You used () instead of {} and the NOT was a bit off.

Customerbuyingmilkthisweek =
VAR Customerlistmilk =
    CALCULATETABLE (
        VALUES ( 'Distinctcustomer'[LocationReference] ),
        'Weekly Data'[Weeknum] = MAX ( 'Weekly Data'[Weeknum] ),
        'Weekly Data'[Product Catagory1_3] = "Milk"
    )
VAR Customerlistother =
    CALCULATETABLE (
        VALUES ( 'Distinctcustomer'[LocationReference] ),
        'Weekly Data'[Weeknum] = MAX ( 'Weekly Data'[Weeknum] ),
        'Weekly Data'[Product Catagory1_3] IN { "Bread", "Groceries", "Creams" }
    )
RETURN
    COUNTROWS (
        FILTER ( Customerlistmilk, NOT ( Customerlistmilk ) IN { Customerlistother } )
    )

Still unable to understand why countrown is resturning multiple values when this return scalar. However except works really good! Thanks

jdbuchanan71
Super User
Super User

Try it using EXCEPT

Customerbuyingmilkthisweek =
VAR Customerlistmilk =
    CALCULATETABLE (
        VALUES ( 'Distinctcustomer'[LocationReference] ),
        'Weekly Data'[Weeknum] = MAX ( 'Weekly Data'[Weeknum] ),
        'Weekly Data'[Product Catagory1_3] = "Milk"
    )
VAR Customerlistother =
    CALCULATETABLE (
        VALUES ( 'Distinctcustomer'[LocationReference] ),
        'Weekly Data'[Weeknum] = MAX ( 'Weekly Data'[Weeknum] ),
        'Weekly Data'[Product Catagory1_3] IN { "Bread", "Groceries", "Creams" }
    )
VAR CustomerMilkOnly =
    EXCEPT ( Customerlistmilk, Customerlistother )
RETURN
    COUNTROWS ( CustomerMilkOnly )

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors