The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I am using PBI report builder with row grouping. I am trying to get a count of 3 catagories within a parent category. The grouping works if the value is present but I would like to report zero counts too. For example, grouping by title, sub-grouping by status, I have 3 count groupings for status, "APPROVED", "REVOKED", "PENDING". If "REVOKED" does not have any records, it does not report. I need it to report zero. How can I do this?
Solved! Go to Solution.
Found a solution:
select id, review_name, updated_dt,
(select count(*) from
ara.review_entry re
where re.review_id = r.id and re.review_decision = 'APPROVED'
) as approved,
(select count(*) from
review_entry re
where re.review_id = r.id and re.review_decision = 'REVOKED'
) as revoked,
(select count(*) from
review_entry re
where re.review_id = r.id and re.review_decision = 'PENDING'
) as pending
from review r
Found a solution:
select id, review_name, updated_dt,
(select count(*) from
ara.review_entry re
where re.review_id = r.id and re.review_decision = 'APPROVED'
) as approved,
(select count(*) from
review_entry re
where re.review_id = r.id and re.review_decision = 'REVOKED'
) as revoked,
(select count(*) from
review_entry re
where re.review_id = r.id and re.review_decision = 'PENDING'
) as pending
from review r
As in the examples below, the "REVOKED" value is missing from the grouping for "test 123" because this value is missing from the data. I want to report the zero value as shown in the other image. I tried this but got the same results as before
=IIF(Count(Fields!decision.Value, "Review", Recursive) = 0, 0,
Count(IIF(Fields!decision.Value= "REVOKED", 1, Nothing), "Review", Recursive))
Hi @tantle61 ,
Please have a try.
=IIF(Count(Fields!Status.Value, "DataSet1", Recursive) = 0, 0, Count(IIF(Fields!Status.Value = "REVOKED", 1, Nothing), "DataSet1", Recursive))
In this example, is the name of the dataset that contains the data you want to count. The function is used twice: once to check if there are any records for the “REVOKED” category, and again to count the number of records for the “REVOKED” category if there are any. The function is used to return a value of 0 if there are no records for the “REVOKED” category.DataSet1CountIIF
You can modify this expression to count the number of records for other categories as well. Simply replace with the name of the category you want to count."REVOKED"
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
25 | |
15 | |
14 | |
12 |
User | Count |
---|---|
110 | |
40 | |
25 | |
24 | |
19 |