Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello All, good morning.
I am stuck in a DAX measure related to ABC Customer Segmentation. My current formula is as below:
I believe the issue is related to the or clause, for this customer, due to the revenue it falls in the A category, but due to profit in B... But I want to always return the highest one.
Could anyone help me?
Solved! Go to Solution.
@Okazakipedro , Check this if it meets your requirement
Proud to be a Super User! |
|
Hi @Okazakipedro ,
Did @bhanu_gautam reply solve your problem? If so, please mark it as the correct solution, and point out if the problem persists.
Best regards,
Adamk Kong
@Okazakipedro , Try using
category_abcProfitEurr =
VAR SalesByProduct =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( Fact_JobFinancials, Fact_JobFinancials[Controlling Customer Code] ),
"@ProdSales", [job_totalProfitEur]
),
ALLSELECTED ( Fact_JobFinancials )
)
VAR AllSales =
CALCULATE (
[job_totalProfitEur],
ALLSELECTED ( Fact_JobFinancials )
)
VAR ProductsInClass =
FILTER (
CROSSJOIN (
SalesByProduct,
'Support_Category&Date'
),
([job_totalProfitEur] > 'Support_Category&Date'[ProfitLowerBoundaries]
&& [job_totalProfitEur] <= 'Support_Category&Date'[ProfitUpperBoundaries])
||
([job_totalRevenueEur] > 'Support_Category&Date'[RevenueLowerBoundaries]
&& [job_totalRevenueEur] <= 'Support_Category&Date'[RevenueUpperBoundaries])
)
VAR CategoryA =
CALCULATE (
[job_totalProfitEur],
KEEPFILTERS ( ProductsInClass ),
'Support_Category&Date'[Category] = "A"
)
VAR CategoryB =
CALCULATE (
[job_totalProfitEur],
KEEPFILTERS ( ProductsInClass ),
'Support_Category&Date'[Category] = "B"
)
VAR CategoryC =
CALCULATE (
[job_totalProfitEur],
KEEPFILTERS ( ProductsInClass ),
'Support_Category&Date'[Category] = "C"
)
VAR Result =
IF (
NOT ISBLANK(CategoryA), CategoryA,
IF (
NOT ISBLANK(CategoryB), CategoryB,
CategoryC
)
)
RETURN
Result
Proud to be a Super User! |
|
@bhanu_gautam ID did not work, but I am attaching a file so you can see what is the problem, would really appreciate your inputs 🙂
-- Edit, it seems that I can't post the sample pbix, therefore I am writing everything here, sorry:
Fact Table (SampleData)
Shipment_Branch_Quarter_PK | ShipmentID | ShipmentNo | job_totalRevenueEur | job_totalProfitEur | Controlling Customer Code |
STR-SSTR00001098-2024-Q1 | 543A78E1-18D7-467A-BECC-52C12018DBB2 | SSTR00001098 | 6.880, € | 756,27 € | ALAHLISAF |
STR-SSTR00001167-2024-Q1 | 439B06A3-E0EF-4E2C-83E7-A0CED138D27E | SSTR00001167 | 0, € | 0, € | ALAHLISAF |
STR-SSTR00001167-2024-Q2 | 439B06A3-E0EF-4E2C-83E7-A0CED138D27E | SSTR00001167 | 815.449,32 € | 43.503,53 € | ALAHLISAF |
STR-SSTR00001167-2024-Q3 | 439B06A3-E0EF-4E2C-83E7-A0CED138D27E | SSTR00001167 | 0, € | -10.240,86 € | ALAHLISAF |
STR-SSTR00001250-2024-Q3 | 32DCA1DD-0758-45A4-86BF-DFB596B9FA1A | SSTR00001250 | 11.700, € | 895,97 € | ALAHLISAF |
Dimenstion (Support_Category)
Category | ProfitLowerBoundaries | ProfitUpperBoundaries | RevenueLowerBoundaries | RevenueUpperBoundaries |
A | 50000 | 1000000000 | 250000 | 1000000000 |
B | 12500 | 50000 | 50000 | 250000 |
C | -1000000000 | 12500 | -1000000000 | 50000 |
Current measure
Thanks!
@Okazakipedro , Check this if it meets your requirement
Proud to be a Super User! |
|
Hello Bharu, thanks for the reply, but still got the same result...
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
104 | |
75 | |
46 | |
39 | |
33 |
User | Count |
---|---|
165 | |
90 | |
66 | |
46 | |
43 |