Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all
I don't really know how to go about searching for the solution for this as I'm not quite sure what the keywords should be...
I'm designing a model based on customer payments and am looking to produce figures for customers who have had a payment fall through ('payment reversed'), but have also made a payment successfully in the same month ('payment not reversed'). Not bothered about the order of events at this stage. I have measures to calculate counts for each separately, but I'm not sure how to go about isolating the inner portion of the Venn diagram!
I have a solution which filters based on measure outputs but the performance is horrible (as I knew it would be). I would have thought I should be
1. pulling a list of account IDs that have a reversal in the month
2. storing that in a VAR
3. applying that list of account IDs as a filter in a CALCULATE(count of successful payments)
Unfortunately my career in DAX is pretty young so I'm getting coder's block when I try to take that many steps in one fell swoop! I'm getting a mental block particularly around populating a VAR with a column of reversed Account IDs rather than pulling a full table, and it seems like a PITA to try and take a particular column out of a table VAR.
Help!
Solved! Go to Solution.
[Accounts with both Successful and Failed Direct Debits in Month] := CALCULATE( var __accountsWithSuccessfulPayment = calculatetable ( summarize ( TRANSACTIONS, ACCOUNTS[AccountID], DIMDATES[MonthEndDate] ), TRANSACTIONS[HasBeenReversed_Int] = 0 ) var __accountsWithFailedPayment = calculatetable ( summarize ( TRANSACTIONS, ACCOUNTS[AccountID], DIMDATES[MonthEndDate] ), TRANSACTIONS[HasBeenReversed_Int] = 1 ) var __accountsWithBoth = intersect ( __accountsWithSuccessfulPayment, __accountsWithFailedPayment ) return countrows ( __accountsWithBoth ), KEEPFILTERS(DIMTRANSACTIONTYPES[PaymentEntryTypeName] = "Payment Received"), KEEPFILTERS(DIMTRANSACTIONTYPES[PaymentMethodGroup]= "Direct Debit"), KEEPFILTERS(DIMTRANSACTIONCodes[GlobalAccountType] = "Mortgage"), USERELATIONSHIP(DIMDATES[DateKey], TRANSACTIONS[SKeyDatePeriodEnd]) )
Here's you measure withouth GROUPBY.
Best
Darek
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
26 | |
21 | |
16 | |
12 |
User | Count |
---|---|
57 | |
49 | |
44 | |
19 | |
18 |