March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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
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
Solved! Go to Solution.
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.
Update:
Already have the answer but kinda complicated.
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
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.
Hi @Fxelixe
please try
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 ) )
Update:
Already have the answer but kinda complicated.
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
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.
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
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.
Thank you so much for helping me getting be better on dax. really appreciate it
yes i also think the same idea hahaha. thank you, i hope in the future someone will be helped by this thread
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.
yes I already think to use AND, but AND logic only works for 2 item. I need flexibilities to determine # of products
you can use && to combine Boolean expressions as many as possible.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
27 | |
18 | |
16 | |
12 | |
11 |
User | Count |
---|---|
38 | |
29 | |
28 | |
20 | |
18 |