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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Counting from multiple columns (DAX)

Hi, 

 

I am trying to obtain a count, but including the results of more than one column.

 

With the data gived as following:

OCM37_0-1637772033363.png

 

I would like to obtain a a visualization like the following, but for the agrupattion of both columns, not only SYMPTOM1

OCM37_1-1637772236358.png

 

The thing is that the values placed in SYMPTOM1, and SYMPTOM2, could be the same, but I want to count the total for both of them.

 

Do you know how I can I do this count?

 

Thank you in advance! 🙂

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may need to transform the table using the following formula:

NewTable = 
var _t1= SELECTCOLUMNS('Table',"VALUES_ID",[VALUES_ID],"SYMPOM",[SYMPOM1],"SYMPTOMVERSION",[SYMPTOMVERSION1])
var _t2= SELECTCOLUMNS('Table',"VALUES_ID",[VALUES_ID],"SYMPOM",[SYMPOM2],"SYMPTOMVERSION",[SYMPTOMVERSION2])
return UNION(_t1,_t2)

Eyelyn9_0-1638236139553.png

Output:

 

Eyelyn9_1-1638236208697.png

Eyelyn9_3-1638236361662.png

Eyelyn9_4-1638236385324.png

 

Best Regards,
Eyelyn Qin
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
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may need to transform the table using the following formula:

NewTable = 
var _t1= SELECTCOLUMNS('Table',"VALUES_ID",[VALUES_ID],"SYMPOM",[SYMPOM1],"SYMPTOMVERSION",[SYMPTOMVERSION1])
var _t2= SELECTCOLUMNS('Table',"VALUES_ID",[VALUES_ID],"SYMPOM",[SYMPOM2],"SYMPTOMVERSION",[SYMPTOMVERSION2])
return UNION(_t1,_t2)

Eyelyn9_0-1638236139553.png

Output:

 

Eyelyn9_1-1638236208697.png

Eyelyn9_3-1638236361662.png

Eyelyn9_4-1638236385324.png

 

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

Anonymous
Not applicable

Thank you for the solution, it works 🙂

 

I also thought I may use Power Query to UNPIVOT the columns and analyze the resulting table.

 

Thank you! 

VahidDM
Super User
Super User

Hi @Anonymous 

 

Can you post sample data as text and expected output?
Not enough information to go on;

please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
4. Relation between your tables

Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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