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
newbie9
Helper I
Helper I

count of columns

hi,

I have created a field parameter with columns from a table

now I need to get the count of rows from the columns selected

 

ex.

if a, b and c are columns and are involved in field parameter creation

count of a = 12

count of b = 10

count of c = 15

summarizing count of a and b = 10

summarizing count of c and b = 14

summarizing count of a and c = 15

 

so if column a and b are selected, I should get the count as 10 and only column c is selected then I should get 15 and so on for others

 

thanks in advance

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @newbie9 ,

Below is my table:

vxiandatmsft_0-1707207787888.png

The following DAX might work for you:

Selected Column Count = 
var tmp1=FILTER(ALL('Table'),[a]<>BLANK()&&[b]<>BLANK())
var tmp2=FILTER(ALL('Table'),[a]<>BLANK()&&[c]<>BLANK())
var tmp3=FILTER(ALL('Table'),[c]<>BLANK()&&[b]<>BLANK())
var ab_count=COUNTROWS(tmp1)
var ac_count=COUNTROWS(tmp2)
var bc_count=COUNTROWS(tmp3)
var tmp4=SELECTCOLUMNS(Parameter,"PT",[Parameter])
var  _str =CONCATENATEX(tmp4,[PT])

return
SWITCH(TRUE(),
   _str = "a" , COUNT('Table'[a]),
   _str = "b" , COUNT('Table'[b]),
   _str = "c" , COUNT('Table'[c]),
   _str = "ab" , CALCULATE(COUNTROWS('Table'),tmp1),
   _str = "bc" , CALCULATE(COUNTROWS('Table'),tmp3),
   _str = "ac" , CALCULATE(COUNTROWS('Table'),tmp2) 
)

The final output is shown in the following figure:

vxiandatmsft_1-1707208056879.png

Best Regards,

Xianda Tang

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

2 REPLIES 2
Anonymous
Not applicable

Hi @newbie9 ,

Below is my table:

vxiandatmsft_0-1707207787888.png

The following DAX might work for you:

Selected Column Count = 
var tmp1=FILTER(ALL('Table'),[a]<>BLANK()&&[b]<>BLANK())
var tmp2=FILTER(ALL('Table'),[a]<>BLANK()&&[c]<>BLANK())
var tmp3=FILTER(ALL('Table'),[c]<>BLANK()&&[b]<>BLANK())
var ab_count=COUNTROWS(tmp1)
var ac_count=COUNTROWS(tmp2)
var bc_count=COUNTROWS(tmp3)
var tmp4=SELECTCOLUMNS(Parameter,"PT",[Parameter])
var  _str =CONCATENATEX(tmp4,[PT])

return
SWITCH(TRUE(),
   _str = "a" , COUNT('Table'[a]),
   _str = "b" , COUNT('Table'[b]),
   _str = "c" , COUNT('Table'[c]),
   _str = "ab" , CALCULATE(COUNTROWS('Table'),tmp1),
   _str = "bc" , CALCULATE(COUNTROWS('Table'),tmp3),
   _str = "ac" , CALCULATE(COUNTROWS('Table'),tmp2) 
)

The final output is shown in the following figure:

vxiandatmsft_1-1707208056879.png

Best Regards,

Xianda Tang

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

PijushRoy
Super User
Super User

Hi @newbie9 

Please share sample data or sample pbix file link with expected result to get answer quickly
https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

 

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors