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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.