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 Friends,
I have attached data table below:
I need distinct count of CustomerID for "V1-V2" Common Vertical.
Note: If any customer have only "V1" Vertical and "V1-V2-V3" then it will not count as V1-V2 Common Vertical.
Expected Output:
From dataset image only 2 customer in V1-V2 common group. so measure will give me 2 count.
Please help me out how to write dax for this type of condition.
Thank you once again in advance...!!!
Solved! Go to Solution.
@ravi_609
I tested withthe sample youprovided and it worked for me.can you explain how are youtrying to apply this measure?
My table:
The meaure and the result:
Porvide more details and screenshots of the error. You may also share dummy data that represent your actual data structure.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Share data in a format that can be pasted in an MS Excel file. Sharing an image is useless!!!!
@ravi_609
Try this measure:
COUNTROWS(
FILTER(
ADDCOLUMNS(
DISTINCT(Table06[CustomerID] ),
"V" ,
VAR __A = COUNTROWS( CALCULATETABLE( VALUES( Table06[Vertical] ) , TREATAS( {"V1" ,"V2"} , Table06[Vertical] )) )
VAR __B = COUNTROWS(CALCULATETABLE( VALUES( Table06[Vertical] ) ) )
RETURN
INT(AND(__A=2 ,__B=2))
),
[V] = 1
)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Fowmy Thanks for the response but This measure is not working...!!!
I got solution with SQL Server Query:
SELECT CustomerID,COUNT(Verical)
FROM Vertical
GROUP BY CustomerID
HAVING CustomerID not in (Select CustomerID From Vertical where Verical not in ('V1','V2')) and COUNT(Verical) = 2
But I am stuck here that how to use this same logic into measure.
@ravi_609
I tested withthe sample youprovided and it worked for me.can you explain how are youtrying to apply this measure?
My table:
The meaure and the result:
Porvide more details and screenshots of the error. You may also share dummy data that represent your actual data structure.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
UniqueIDCount =
COUNTROWS(
FILTER(
SUMMARIZE(
YourTable,
YourTable[ID],
"Verticals", CONCATENATEX(VALUES(YourTable[vertical]), YourTable[vertical], ",")
),
(CONTAINSSTRING([Verticals], "V1") && CONTAINSSTRING([Verticals], "V2"))
&& NOT CONTAINSSTRING([Verticals], "V3")
)
)
not the most eloquent solution, but this should work
@Corey_M Thanks for the response but This measure is not working...!!!
I got solution with SQL Server Query:
SELECT CustomerID,COUNT(Verical)
FROM Vertical
GROUP BY CustomerID
HAVING CustomerID not in (Select CustomerID From Vertical where Verical not in ('V1','V2')) and COUNT(Verical) = 2
But I am stuck here that how to use this same logic into measure.
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 |
---|---|
100 | |
100 | |
80 | |
77 | |
66 |
User | Count |
---|---|
134 | |
106 | |
104 | |
85 | |
73 |