Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tantle61
New Member

Grouping to include missing values

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?

 

1 ACCEPTED SOLUTION
tantle61
New Member

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

View solution in original post

3 REPLIES 3
tantle61
New Member

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

tantle61
New Member

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))

Revoked.pngCorrected.png

v-rongtiep-msft
Community Support
Community Support

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"

Expression examples in paginated reports - Microsoft Report Builder & Power BI Report Builder | Micr...

Count function in a paginated report - Microsoft Report Builder & Power BI Report Builder | Microsof...

 

 

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.

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors