Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi
My first post, so appologies for the clumsiness.
So I have 2 tables, Documents and Attachments.
To keep it simple, documents has 1 relevant column witch is the HeaderId (the ID of the document).
The Attachments also have only 1 relevant column witch is ID
So I am looking to have a table where I get how many attachments a certain document has.
looks like this:
HeaderID | NrOfAttachments |
Doc1 | 0 |
Doc2 | 5 |
Doc3 | 0 |
Doc4 | 3 |
The first problem I managed to overcome was showing the rows with a 0 as with the count of the Attachment ID's, rows with 0 would not show.
This I did through a measure on the Documents table where the code is:
NrOfAttachments = COUNTROWS(FILTER(documentAttachment, CONTAINS(questionaireQuestions, questionaireQuestions[Id], documentAttachment[No]))) + 0
However when I Add the measure to the table to display, I get an empty row. Like this:
HeaderID | NrOfAttachments |
| 0 |
Doc1 | 0 |
Doc2 | 5 |
Doc3 | 0 |
Doc4 | 3 |
I found a similar issue here: How to remove empty rows but keep zero counts in c... - Microsoft Fabric Community
And tansformed the measure code to:
NrOfAttachments =
VAR _a =
COUNTROWS(FILTER(documentAttachment, CONTAINS(questionaireQuestions, questionaireQuestions[Id], documentAttachment[No]))) + 0
RETURN
IF ( ISBLANK ( _a ), 0, _a )
But that also did not work.
Any one got a solution where I don't have to pollute the filters?
Kind regards
Me
Solved! Go to Solution.
Hi @Arno123
After testing, if your data have the blank field, it will return the blank field.
e.g
Then it will return the blank to 0
You can check it and change the code to the following
NrOfAttachments =
VAR _a =
COUNTROWS (
FILTER (
documentAttachment,
CONTAINS (
questionaireQuestions,
questionaireQuestions[Id], documentAttachment[No]
)
)
) + 0
RETURN
IF (
SELECTEDVALUE ( questionaireQuestions[HeaderID] ) <> BLANK,
IF ( ISBLANK ( _a ), 0, _a )
)
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Arno123
After testing, if your data have the blank field, it will return the blank field.
e.g
Then it will return the blank to 0
You can check it and change the code to the following
NrOfAttachments =
VAR _a =
COUNTROWS (
FILTER (
documentAttachment,
CONTAINS (
questionaireQuestions,
questionaireQuestions[Id], documentAttachment[No]
)
)
) + 0
RETURN
IF (
SELECTEDVALUE ( questionaireQuestions[HeaderID] ) <> BLANK,
IF ( ISBLANK ( _a ), 0, _a )
)
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I'm not sure, but perhaps something like this will help solve your problem
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
73 | |
57 | |
38 | |
35 |
User | Count |
---|---|
83 | |
68 | |
59 | |
46 | |
45 |