The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Solved! Go to Solution.
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 )
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
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 )