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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Pwrbi_usr
Regular Visitor

DAX formula count single value in D365 multiselect field

 

Hello, 

In a Power Bi report, connected to Dynamics 365 environment by direct query, i need to count how many times a single value (1) of a multiselect field appears in the column.

Examining the input data, I found that the values have the following format:

 

Immagine 2024-06-06 100028.png

 

 

 

 

 

 

 

 

I tried with the following expression, but it counts every single row:

Single option = CALCULATE(COUNTROWS(campaign), NOT(ISBLANK(FIND("1", campaign[Multiselect Field]))))

 

I also tried with this other expression, and count only rows that has the single value "1":

Single option = CALCULATE(COUNTROWS(campaign),CONTAINSSTRING("1", campaign[Destinatari Campagna]))

 

Can someone help me?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Pwrbi_usr 

Thank you very much for your reply. Since the summary will ignore the rows that have the same value. I modified this DAX expression:

vjianpengmsft_0-1718256350471.png

This way rows with the same value will not be ignored, and the final DAX expression will look like this:

Has1value = 
VAR _table = ADDCOLUMNS(CALCULATETABLE('Table'),"a",FIND(1,'Table'[Column1],1,0))
RETURN COUNTAX(FILTER(_table,[a] <>0),'Table'[Column1])

vjianpengmsft_1-1718256441390.png

I've uploaded the PBIX file I used this time below.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @Pwrbi_usr 

Based on your description, I've created the following sample data:

vjianpengmsft_0-1717731844192.png

Using the Find function is the right choice. First, I created a dummy table in my measure as follows:

vjianpengmsft_1-1717731912264.png

Second, I use the countax function to count the column columns. The final measure expression is as follows:

Has1value = 
VAR _table = SUMMARIZE('Table','Table'[Column1],"a",FIND(1,'Table'[Column1],1,0))
RETURN COUNTAX(FILTER(_table,[a] <>0),'Table'[Column1])

Here are the results:

vjianpengmsft_2-1717732020648.png

I've uploaded the PBIX file I used this time below.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

I tried your  DAX expression, but if there is the same value in multiple rows, only one is considered:

 

img2.png

 

 

 

 

 

 

 

 

 

 

While in input I've 10 rows:

 

Immagine 2024-06-06 100028.png

Anonymous
Not applicable

Hi, @Pwrbi_usr 

Thank you very much for your reply. Since the summary will ignore the rows that have the same value. I modified this DAX expression:

vjianpengmsft_0-1718256350471.png

This way rows with the same value will not be ignored, and the final DAX expression will look like this:

Has1value = 
VAR _table = ADDCOLUMNS(CALCULATETABLE('Table'),"a",FIND(1,'Table'[Column1],1,0))
RETURN COUNTAX(FILTER(_table,[a] <>0),'Table'[Column1])

vjianpengmsft_1-1718256441390.png

I've uploaded the PBIX file I used this time below.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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