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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
danning1234
Advocate I
Advocate I

Customer buy product type A and B with amount > 100

Hi, 

 

I have a dim table Customer, dim table Product and a fact table Sales (and other dim tables like date, stores, ...).

What i want to achieve is to mark Customers and Products, when the Customer buy product type A and B with an amount > 100.

 

Basicaly, I want a list of customer and their products, when the customer buy both product type A and B with an amount greater than 100.

 

Ex:

 

Customer     Product     ProductType     Amount    WantedMeasureResult

1                   11              A                       100           0, because Cust1 buy only 

1                   12              A                       200           0, because Cust1 buy only 

2                   13              A                       100           0, because Cust2 buy both A and B but the amount is not > 100

2                   14              A                       200           1, because Cust2 buy both A and B and the amount is > 100

2                   15              B                       200           1, because Cust2 buy both A and B and the amount is > 100

 

Thanks.

 

3 REPLIES 3
danning1234
Advocate I
Advocate I

@Anonymous @amitchandak 

 

Thanks for your answers, but they dont work.

I am writing a measure like below but not sure how to write the return part... 

(Core and CAP is like type A and B, the model is a star shema, dim filters the data table and it is all 1 to many.)

 

Check =
VAR listCust =
VALUES ( Dim_Customer[CustomerNumber] )
VAR listCustWithCore =
FILTER (
listCust,
COUNTROWS (
FILTER (
RELATEDTABLE ( Data_Balance_Port02 ),
RELATED ( Dim_Loan[FlagCovidDesc] ) = "Core"
&& [Amnt] > 0
)
) > 0
)
VAR listCustWithCap =
FILTER (
listCust,
COUNTROWS (
FILTER (
RELATEDTABLE ( Data_Balance_Port02 ),
RELATED ( Dim_Loan[FlagCovidDesc] ) = "CAP"
&& [Amnt] > 0
)
) > 0
)
RETURN
??
Anonymous
Not applicable

WantedResultMeasure = 
var x=CALCULATE(CONCATENATEX(VALUES(t1[Type]),t1[Type],",",t1[Type],ASC),ALLEXCEPT(t1,t1[Customer]))
var y=Len(x)
Return
IF(y>1, 
   IF(SUM(t1[Amount])>100,
    "1, because Cust"&SELECTEDVALUE(t1[Customer])& " buy both A and B and the amount is > 100",
    "0, because Cust"&SELECTEDVALUE(t1[Customer])& " buy both A and B but the amount is not > 100"),
"0, because Cust"&SELECTEDVALUE(t1[Customer])& " buy only")

DAx1PNG.PNG

amitchandak
Super User
Super User

@danning1234 , Try like

if( calculate( distinctcount([ProductType]),filter(Table,[Customer] =earlier([Customer]) && [Amount] > 100 && [ProductType] in {"A","B"}))=2,1,0)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.