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.
Hello,
I'm struggeling to get this answer.
My customers have mulptiple contacts, with different roles. I want to summurize in a column if a customer has a contact with a certain rol or not.
I have one table with :
Account ID | Rol | HAS A? |
1 | A | Y |
1 | B | Y |
2 | A | Y |
2 | C | Y |
3 | B | N |
3 | B | N |
I don't know how to write the right DAX-formula.
Thansk for you help,
Bart
// T is your table.
[Has A?] = // calc column
var __account = T[Account]
var __hasA =
NOT ISEMPTY(
FILTER(
T,
T[Account] = __account
&&
T[IDRol] = "A"
)
)
RETURN
if( __hasA, "Y", "N" )
Best
D
I agree it is better to right a measure when you can. But also here is an expression for your calculated column.
HasA = if(calculate(Countrows(YourTable), All(YourTable), YourTable[Rol]="A", YourTable[Account ID]=Earlier(YourTable[Account ID]))>0, "Y", "N")
If this solution works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @BartStruyf,
First of all, I would not recommend to use calculated column for this task. A measure would be more appropriate.
But to solve your problem you might do the following.
If you don't have separate dimension table for Roles you need to:
1. Create a measure [Num of unique Roles]: = DISTINCTCOUNT('YourTable'[IDRol])
2. Create a calculated column: = CALCULATE([Num of unique Roles];filter(VALUES('YourTable'[IDRol]);'YourTable'[IDRol]="A"))>0
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 |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
36 | |
33 | |
18 | |
18 |