cancel
Showing results for
Did you mean:

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Frequent Visitor

## Re:

Hi

So i have trouble to create logic to solve package issue.

the goal is to put remark when customer buy our package which consist of several products

if customer didn't buy the specific product then we remark it as 0, if buy all of the specific products then we remark it as 1

Here's my DAX logic

Package Remark = CALCULATE([Unit Sold],[Unit Sold]>=1.0,filter('Product',[Product Name] IN {"Product A","Product B","Product C","Product D"}))

Here's some excel visualization for the expected output

Well in excel i could easily do COUNT IF cell value >= 1.5 is equal to 6 then 1 , if false 0. then sum it.
but i cannot do that easily in power BI. still learning to be better.

Thank you

3 ACCEPTED SOLUTIONS
Super User

Hi,

I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.

It is for creating a measure.

I hope the below can provide some ideas on how to create a solution for your datamodel.

``````Expected output: =
VAR _productAcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product A" ) <> 0
VAR _productBcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product B" ) <> 0
VAR _productCcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product C" ) <> 0
VAR _productDcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product D" ) <> 0
RETURN
IF (
HASONEVALUE ( User[User] ),
_productAcondition * _productBcondition * _productCcondition * _productDcondition
)
``````

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Frequent Visitor

Update:

the idea is to create multiple var to count the products
and then return it using floor
return
floor(item(1)+item(2)+....+Item(n),n)/n

Super User

Hi,

Thank you for your message, and please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

10 REPLIES 10
Super User

Hi @Fxelixe

Package Remark =
VAR Count1 =
COUNTROWS (
FILTER (
VALUES ( 'Product'[Product Name] ),
'Product'[Product Name]
IN { "Product A", "Product B", "Product C", "Product D" }
)
)
RETURN
IF ( ISINSCOPE ( 'Product'[Product Name] ), Count1, IF ( Count1 = 4, 1 ) )

Frequent Visitor

Update:

the idea is to create multiple var to count the products
and then return it using floor
return
floor(item(1)+item(2)+....+Item(n),n)/n

Super User

Hi,

I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.

It is for creating a measure.

I hope the below can provide some ideas on how to create a solution for your datamodel.

``````Expected output: =
VAR _productAcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product A" ) <> 0
VAR _productBcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product B" ) <> 0
VAR _productCcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product C" ) <> 0
VAR _productDcondition =
CALCULATE ( SUM ( Data[Quantity] ), Package[Product Name] = "Product D" ) <> 0
RETURN
IF (
HASONEVALUE ( User[User] ),
_productAcondition * _productBcondition * _productCcondition * _productDcondition
)
``````

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Frequent Visitor

Hi @Jihwan_Kim ,

your dax works and helps me a lot!, but suddenly the problem got more complex for me:

1.  package is valid if each product's sold is >= 1.5
2.  the result can be cumulative on the last solution it would be total = 2
(my hypothesis because if we use IF statement, the calculation will treat them as logical, not cumulative)
3.  each user has one group and the result expected to be summarize by group

Here's the updated table

and then if grouped by "Group"

thank you so much

Super User

Hi,

Thank you for your message, and please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Frequent Visitor

Thank you so much for helping me getting be better on dax. really appreciate it

Frequent Visitor

yes i also think the same idea hahaha. thank you, i hope in the future someone will be helped by this thread

Super User

hi @Fxelixe

IN is OR logic, but it seems you expect a AND logic. Try to modify it firstly.

If the issue persists, it would be necessary to also provide more info about your data model: tables, columns and relationships. It seems you have at least a Product Table and Fact Table, maybe a Customer Table as well.

Frequent Visitor

yes I already think to use AND, but AND logic only works for 2 item. I need flexibilities to determine # of products

Super User

you can use && to combine Boolean expressions as many as possible.