Forum Discussion
Count value in different columns
- 9 years ago
Hi abukapsoun,
If this is the only problem, I would suggest to use a new function "DISTINCTCOUNT".
Measure = DISTINCTCOUNT ( Table1[Name] )
Because only keeping one row would lead another problem that the connection between "country" and "value" would be broken. (the data in red rectangle belongs to no country.)
Best Regards!
Dale
Hi abukapsoun,
Firstly, we need to import the data into Power BI from excel.
Secondly, select "Name" and "Country" with "Ctrl" key. Unpivot three columns "Comp1, Col2, Col3".
Thirdly, create a measure.
Count = COUNT(Table1[Value])
I attached the file, you can try it yourself. https://1drv.ms/u/s!ArTqPk2pu-BkgQt-qNdTYX9b5zow
Best Regards!
Dale
- abukapsoun9 years agoPost Patron
Thank you very much Dale..
The unpivot trick worked, but created me another problem.
When unpivotting, it will create extra rows but duplication. So if I unpivot Col1 2 3, and I want to count how many person there is in UK, the value would be 3 instead of 1.
Is there a way I can overcome this problem? Like when unpivotting, only the new created column is filled with values and not the whole row.
Thanks again
- v-jiascu-msft9 years agoMicrosoft Employee
Hi abukapsoun,
If this is the only problem, I would suggest to use a new function "DISTINCTCOUNT".
Measure = DISTINCTCOUNT ( Table1[Name] )
Because only keeping one row would lead another problem that the connection between "country" and "value" would be broken. (the data in red rectangle belongs to no country.)
Best Regards!
Dale