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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
v-xiandat-msft
Community Support
Community Support

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
v-xiandat-msft
Community Support
Community Support

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...

 

 

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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