Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
I have the following tables and relationships:
User
UserId | UserName |
1 | Bill |
2 | John |
3 | Fred |
License
LicenseId | LicenseDesc | UserId |
1 | License A | 1 |
2 | License B | 1 |
3 | License C | 2 |
4 | License D | 2 |
5 | License E | 2 |
6 | License F | 3 |
I want to write a measure that counts the number of rows in the license table (based on the username grouping) and results in the following table:
LicenseId | LicenseDesc | UserName | LicensesAllocated |
1 | License A | Bill | 2 |
2 | License B | Bill | 2 |
3 | License C | John | 3 |
4 | License D | John | 3 |
5 | License E | John | 3 |
6 | License F | Fred | 1 |
I assume I need to use COUNTROWS, but the combinations I have tried either end up with '1' for every value in LicenseAllocated, or a cartesian product.
Any help would be greatly appreciated!
Solved! Go to Solution.
You can try this measure:
LicensesAllocated =
CALCULATE(COUNTROWS(License), FILTER(ALL(License), License[UserId] = SELECTEDVALUE(License[UserId])))
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
You can try this measure:
LicensesAllocated =
CALCULATE(COUNTROWS(License), FILTER(ALL(License), License[UserId] = SELECTEDVALUE(License[UserId])))
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.
Check out my latest demo report in the data story gallery.
Stand with Ukraine!
Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/
Thank you!
HI @ERD , thankyou that worked perfectly!
Out of interest, do you know why it wouldn't calculate the total for this measure?
Kind regards,
Ben.
Yes, sorry I need a measure not a calculated column on a table.
Hi @bhalicki ,
As per your requirement of getting count of Licenses per User, you should create a column in the User Table with below DAX expression.
License Allocated = CALCULATE(COUNTROWS(License), FILTER(License, License[UserId] = User[UserId]))
Add columns in the table and you can see the expected result will include the License Allocated by each user.
If this answer helps, please mark it as an Accepted Solution so it would help others to find the solution.
Thanks!
Inogic Professional Service Division
An expert technical extension for your techno-functional business needs
Power Platform/Dynamics 365 CRM
Drop an email at crm@inogic.com
Service: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
Hi @SamInogic ,
Thanks for your quick reply! I tried your solution, but I get:
This is the measure (note the RELATED function):
License table:
Any ideas?
Hi @bhalicki
It seems that you followed the steps for the solution but created measure instead of the Column in the table.
Can you check the above DAX as a column in the table and add on the report to check output?
Thanks!
Inogic Professional Service Division
An expert technical extension for your techno-functional business needs
Power Platform/Dynamics 365 CRM
Drop an email at crm@inogic.com
Service: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
12 | |
10 | |
10 | |
9 |