cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nejovic Regular Visitor
Regular Visitor

Addition Problem

Hi, 

I'll try to explain my problem with example.

This is my data:

data.PNG


I want to create visualization that will show the total number of 'As', 'Bs', 'Cs' and 'Ds' in my four columns. So the result should be: 

 

A - 5

B - 4

C - 2

D - 1

 

What I did was: I choosed Clustered Bar Chart > Insert Column 1 in Values > New Quick Measure > Addition > Added Colum 2 > New Quick Measure > Addition > Added Column 3 > New Quick Measure > Addition > Added Column 4. 

What I got is this:

Addition.PNG
As you can see, this is not the result I wanted. I got 6 Bs, 4 As, 2 Cs, and no Ds, which doesn't correspond to the real data. 

What should I do to get the correct result? 

I'd really appreciate your help. 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
moumipanja Regular Visitor
Regular Visitor

Re: Addition Problem

You might use Power Query  to reshape your table and then create a measure using DAX to show the count of occurences. Hope this solution helps.

1. Click on Edit Queries -> select Transform tab -> select all your columns and then click on unpivot columns

 

1.PNG

 

2. once done, you will get the following table

2.jpg

3. Click on Close and apply. Now use the following DAX to create a measure as below:

Measure Count = COUNTROWS(Sheet1)
 
4. Select clustered bar chart -> Value in Axis and Legend, Measure Count in Value
 
3.PNG
5 REPLIES 5
AClerk New Contributor
New Contributor

Re: Addition Problem

HI @Nejovic

How about creating measures like --> 

COUNTA = COUNTROWS(FILTER(Table1,Table1[1] = "A")) + COUNTROWS(FILTER(Table1,Table1[2] = "A")) + COUNTROWS(FILTER(Table1,Table1[3] = "A")) + COUNTROWS(FILTER(Table1,Table1[4] = "A"))

And then showing a visual for all measures?
Is that applicable?

2019-01-29 09_52_28-Clipboard.png

 

 

Highlighted
Vvelarde Super Contributor
Super Contributor

Re: Addition Problem

@Nejovic

 

Hi, you can go to Edit Query, Select your columns and Apply an Unpivot Columns. Finally delete empty rows

 

Now with this, just apply a simple count in your visual

 

Regards

 

Victor

 




Lima - Peru
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




moumipanja Regular Visitor
Regular Visitor

Re: Addition Problem

You might use Power Query  to reshape your table and then create a measure using DAX to show the count of occurences. Hope this solution helps.

1. Click on Edit Queries -> select Transform tab -> select all your columns and then click on unpivot columns

 

1.PNG

 

2. once done, you will get the following table

2.jpg

3. Click on Close and apply. Now use the following DAX to create a measure as below:

Measure Count = COUNTROWS(Sheet1)
 
4. Select clustered bar chart -> Value in Axis and Legend, Measure Count in Value
 
3.PNG
Nejovic Regular Visitor
Regular Visitor

Re: Addition Problem

Thank you everyone! 
 

This method with unpivoting columns works if I only had these 4 columns. However, I have additional columns, and when I unpivot these columns, that disrupts my statistics for other variables. 

moumipanja Regular Visitor
Regular Visitor

Re: Addition Problem

Just a thought. You can create a new table using those 4 columns, unpivot it and get the desired result. For rest of the calculations you can use your original table. Let me know if this works.

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 108 members 1,627 guests
Please welcome our newest community members: