Forum Discussion
Count records in table ignoring groups in a table in Power Bi
Hi,
I want to get pecentage per group i.e Total value of a Group/ Total Value
I am trying to get total value of all groups from the data table but when I put that measure in a table it gets divided by groups which I don't want.
If I used "ALL" in measure then it will even ignore Date but I need my measure to be filtered by date not by group.
Data Table:
| ID | Group | Date |
| 12 | TUI | 01/02/2023 |
| 13 | FOR | 02/02/2023 |
| 14 | GPP | 03/02/2023 |
| 15 | FOR | 04/02/2023 |
| 16 | FOR | 05/02/2023 |
| 17 | TUI | 06/02/2023 |
| 18 | FOR | 07/02/2023 |
| 19 | GPP | 08/02/2023 |
| 20 | GPP | 09/02/2023 |
Output Table:
| Table Columns | Measure | ||
| Group | Count | Total Count | Percentage |
| TUI | 2 | 8 | 0.25 |
| FOR | 4 | 8 | 0.5 |
| GPP | 3 | 8 | 0.375 |
Measure that I Created:
- Anonymous3 years ago
Hi Raj12 ,
Why is the total 8 and not 9?Please check if this is your expected output.
pecentage per group = VAR _count = COUNTROWS('Table') VAR _count_all = CALCULATE(COUNTROWS('Table'),ALL()) VAR _result = DIVIDE(_count,_count_all) RETURN _resultIf you need the total to always be at 100%, try this.
VAR _count = COUNTROWS('Table') VAR _count_all = CALCULATE(COUNTROWS('Table'),ALLSELECTED()) VAR _result = DIVIDE(_count,_count_all) RETURN _resultBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
2 Replies
- AnonymousNot applicable
Hi Raj12 ,
Why is the total 8 and not 9?Please check if this is your expected output.
pecentage per group = VAR _count = COUNTROWS('Table') VAR _count_all = CALCULATE(COUNTROWS('Table'),ALL()) VAR _result = DIVIDE(_count,_count_all) RETURN _resultIf you need the total to always be at 100%, try this.
VAR _count = COUNTROWS('Table') VAR _count_all = CALCULATE(COUNTROWS('Table'),ALLSELECTED()) VAR _result = DIVIDE(_count,_count_all) RETURN _resultBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
- Raj12
Helper III
Can anyone please help me out on this?
Thanks