Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
User232431
Helper III
Helper III

Need a DAX function to get unique count of values separated by "comma" excluding Blanks

Hi I have table containd column as Values (which has comma seperated values) , how can i get unique count of values based on slicer selection,

 

ex: Year = 2025 , Month = 1 , Country = ind , the result will be  "4" (unique values  - 20,30,40,13)

ex2 : Year = 2025 , Month = 1 , Country = ind ,Market = MH then the result will be "3" (unique values - 20,30,40)

ex3 : Year = 2025 , Month = 1 , Country = ind ,Market = MH then the result will be "3" (unique values - 20,30,40)

ex4 : Year = 2025 , Month = 1 , Country = Mal ,Market = KU , Branch = B1 then the result will be "0" (Blanks)

 

Yearmonthcountrymarketbranchvalues
20251IndMHMUM20,30,40,20,30
20251IndMHMUM 
20251IndMHNag30,40
20251IndKHKan13,30,40,20,30
20251MalKUB1 

 

I have tried with below Dax , but not achieving desired output

 

_Unique_Concatenation_Count =


VAR UniqueValues =
    DISTINCT(
        VALUES(t2_Main[Den2])
    )
RETURN
COUNTROWS(UniqueValues)
 
Need help on to accurate output. Thanks
1 ACCEPTED SOLUTION

lbendlin_0-1743424205622.png

Unique Measure = 
var a = SUBSTITUTE(CONCATENATEX('Table',[values],"|"),",","|")
RETURN IF(PATHLENGTH(a)=0,0,
VAR b = GENERATE(GENERATESERIES(1, PATHLENGTH(a)), SELECTCOLUMNS ({PATHITEM(a, [Value])}, "Val", [Value]))
RETURN COUNTROWS(SUMMARIZE(b, [Val])))

 

View solution in original post

6 REPLIES 6
lbendlin
Super User
Super User

lbendlin_1-1743179879114.png

 

Note that you don't have blanks in the second row. You have a string " " which counts as a distinct value.

 

Thanks you for your reply ,  Can we convert it into dynaic measure ? so that it can calculate according to the slicer that i selected. Thanks you very much

You mean you want to calculate this across rows rather than for each row separately?

Yes , i want the measure that will be used in Card visual. Thank you

lbendlin_0-1743424205622.png

Unique Measure = 
var a = SUBSTITUTE(CONCATENATEX('Table',[values],"|"),",","|")
RETURN IF(PATHLENGTH(a)=0,0,
VAR b = GENERATE(GENERATESERIES(1, PATHLENGTH(a)), SELECTCOLUMNS ({PATHITEM(a, [Value])}, "Val", [Value]))
RETURN COUNTROWS(SUMMARIZE(b, [Val])))

 

Yes , Thank you

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.