Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Dear Community,
I am very new to power BI. This could be simple requirement but I am struggling to make it work.
Here is my requirement :
DAX to calculate dynamically within group.
| Type | EMPLID | Calculation | expected result |
| CTA | 1001 | distinct emplid/ count(type) | 0.33 |
| Generic | 1001 | distinct emplid/ count(type) | 0.33 |
| 1001 | distinct emplid/ count(type) | 0.33 | |
| XYZ | 1002 | distinct emplid/ count(type) | 1.00 |
I have Type slicer on the report page and when I select ex: Type ->CTA, Generic then expected result is
| Type | EMPLID | Calculation | expected result |
| CTA | 1001 | distinct emplid/ count(type) | 0.50 |
| Generic | 1001 | distinct emplid/ count(type) | 0.50 |
| 1001 | distinct emplid/ count(type) | ||
| XYZ | 1002 | distinct emplid/ count(type) |
Please help.
Thanks,
Solved! Go to Solution.
@vishwa_sg
measure = divide(distinctcount(emplid), calculate(distinctcount(type), allselected(type)))
@vishwa_sg Here is a link to download a sample solution file:
DAX to calculate dynamically within Selected Group 2022-08-10.pbix
Hi @SpartaBI Thank you so much.
By using your formula. I managed to achieve the expected result. Have to calculate within a group and here is the working DAX
@my pleasure 🙂
P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. Please give it a thumbs up over there if you liked it 🙂https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
@vishwa_sg
measure = divide(distinctcount(emplid), calculate(distinctcount(type), allselected(type)))
@vishwa_sg Here is a link to download a sample solution file:
DAX to calculate dynamically within Selected Group 2022-08-10.pbix
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 13 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 30 | |
| 26 | |
| 17 | |
| 11 | |
| 10 |