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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
bhagyaraj
Frequent Visitor

count multiple from multiple columns into one

Hi,

 

I am trying to count multilple column values into one column.

I have 4 column values BMI,BP,sugar,Lipid respective values normal and abnormal below screen shot for ref.

Kindly sugguest me how to get the count number(Dax Formula) where ever Abnormal exists in 4 columns.

Expectation highlighted in color in below screen shot.

count multiple column.png

 

Thanks...

 

2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey,

 

I'm not sure if this is exactly what you are looking for, the result of the measure looks promising

2017-08-04_10-26-46.png

Here is the measure

Measure = 
SUMX(
UNION(
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim1]),
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim2]),
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim3]),
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim4])			
)
,IF([ContainsA] = "A", 1, 0))

Basically this measure creates a table for each row (maybe you have to put CALCULATE() to its magically use if your table and model much more complex than my simple model.

Than SUMX iterates over the 4 ROWS and sums the result.

 

I created a measure but this should also be usable by creating a calculated column.

 

Cheers

 

[note to myself:  Compare Multiple Columns]



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

Hey,

 

I got other measure formula

Here is the measure

Measure2 = 
            IF(Table1[DIM1]="A",1,0)+
IF(Table1[DIM2]="A",1,0)+
IF(Table1[DIM3]="A",1,0)+
IF(Table1[DIM4]="A",1,0)

 

Thanks for you help.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Is this possible to do with creating a new column instead of measure ??

TomMartens
Super User
Super User

Hey,

 

I'm not sure if this is exactly what you are looking for, the result of the measure looks promising

2017-08-04_10-26-46.png

Here is the measure

Measure = 
SUMX(
UNION(
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim1]),
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim2]),
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim3]),
	SELECTCOLUMNS('Table1',"ContainsA", 'Table1'[Dim4])			
)
,IF([ContainsA] = "A", 1, 0))

Basically this measure creates a table for each row (maybe you have to put CALCULATE() to its magically use if your table and model much more complex than my simple model.

Than SUMX iterates over the 4 ROWS and sums the result.

 

I created a measure but this should also be usable by creating a calculated column.

 

Cheers

 

[note to myself:  Compare Multiple Columns]



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hey,

 

I got other measure formula

Here is the measure

Measure2 = 
            IF(Table1[DIM1]="A",1,0)+
IF(Table1[DIM2]="A",1,0)+
IF(Table1[DIM3]="A",1,0)+
IF(Table1[DIM4]="A",1,0)

 

Thanks for you help.

Hello Mr.Tom,

 

Thanks for query and its works for few records and rest of records shows more then having columns.

For example the formula applied for  7 columns where as the result  shows the value more than 7.

 

Kindly provide any another solution.

Hey,

 

to be of further help you have to provide sampledata, that help to reproduce the wrong beings of my solution.

 

Prepare Excel Data or PBIX using Enter Data and make the file available from onedrive or dropbox.

 

Cheers

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

thanks

Hey,

 

it will help others if you flag my answer as solution and if you like my answer do not hesitate to provide a kudo.

 

Cheers



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.