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 Team,
May be this is a very simple question but I am totally lost doing it and finally would require your help in achieving the result. I have a sample data as below.
Customer | Product |
Ansh | Water |
Prads | Fire |
Kapil | Fire |
Kapil | Water |
Sam | Fire |
Michael | Fire |
Adnam | Water |
Siko | Fire |
Ted | Fire |
Acqua | Water |
Elies | Water |
Board | Fire |
Board | Water |
The requirement is I need to find the distinct count of Customers who have subscribed to both Fire and Water together. So from the above example I should be getting Raj and Board as the 2 distinct customers who haved subscribed to both Fire and Water together.
Request you to kindly assist me with the same.
Please let me know if any additional information required.
Thanks,
Ani
Hi Ani
Please conisder this solution and leave kudos
NO sales = COUNTROWS(Sales) -- number of sales rows
NO fire = CALCULATE(Sales[NO sales],Sales[Product]="Fire") -- number of fire sales rows
NO water = CALCULATE(Sales[NO sales],Sales[Product]="Water") -- number of water sales rows
NO customer with both =
-- number of customers with both fire and water sales rows
CALCULATE(DISTINCTCOUNT(Sales[Customer]),
FILTER(Sales,[NO fire] > 0 && [NO water] > 0)
)
Hi @Ani26 ,
Try this measure:
This should do it.
Count Customers =
COUNTROWS(
FILTER(
ADDCOLUMNS(
SUMMARIZE(
Customers,
Customers[Customer]
),
"Combined Products", CALCULATE(
CONCATENATEX(
Customers,
Customers[Product]
)
)
),
[Combined Products] = "WaterFire"
|| [Combined Products] = "FireWater"
)
)
EDIT: I did that really quick. I prefer things to be a bit more readable and modular. So I like the below better, but they both produce 2 as the answer.
Count Customers =
VAR TempTable =
ADDCOLUMNS(
SUMMARIZE(
Customers,
Customers[Customer]
),
"Combined Products", CALCULATE(
CONCATENATEX(
Customers,
Customers[Product]
)
)
)
VAR JustFireWater =
FILTER(
TempTable,
[Combined Products] = "WaterFire"
|| [Combined Products] = "FireWater"
)
VAR FinalRowCount =
COUNTROWS( JustFireWater )
RETURN
FinalRowCount
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThanks @edhans and @camargos88
Both the solutions helped me get to my answer. Thanks a lot 🙂
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 |
---|---|
111 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |