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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
vivians
Frequent Visitor

DAX count blank rows based on conditions

Hi there, I am trying to create a table and chart based on this data:

Year

Quarter

Team

Return Status

Complaints Working Days

2023/4

Q1

ABC

Nil return

 

2023/4

Q2

ABC

Return

More than 10 working days

2023/4

Q3

ABC

Return

More than 10 working days

2023/4

Q3

ABC

Return

Within 5 working days

2023/4

Q3

ABC

Return

More than 10 working days

2023/4

Q3

ABC

Return

More than 10 working days

2023/4

Q3

ABC

Return

More than 10 working days

2023/4

Q3

ABC

Return

5 - 10 working days

2023/4

Q3

ABC

Return

More than 10 working days

2023/4

Q3

ABC

Return

More than 10 working days

2023/4

Q4

ABC

Non-return

 

 

For each quarter, each team need to submit a report which logs all complaints they have received in that quarter. If a team receive no complain, they will only need to input "Nil return" in the Report Status column, otherwise, they will need to enter "Return" for the column and other details for each complaints. If a team doesn't submit the report, we will mark it as Non-return in the Report Status column.

 

Currently I'm using this measure to count how many complaints have been received:

 

 

N_complaint = COUNT(tbl_report[Return Status]) + 0

I added 0 in this measure because Nil return means there is no complaint, so it allows me to calculate 0 complaint has been received in Q1. However, it also returns 0 for Q4 where no report has been submitted:

vivians_1-1716571521932.png

 

How can I modifiy this measure so that I will have the following inputs:

 

 

N_complaint

Q1

Within 5 working days

0

Q2

5 - 10 working days

0

Q3

More than 10 working days

0

Q2

Within 5 working days

0

Q3

5 - 10 working days

0

Q4

More than 10 working days

1

Q3

Within 5 working days

1

Q3

5 - 10 working days

1

Q3

More than 10 working days

6

Q4

Within 5 working days

(blank)

Q4

5 - 10 working days

(blank)

Q4

More than 10 working days

(blank)

 

vivians_0-1716571491589.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @vivians ,

Please try this measure:

N_complaint = 
VAR __count1 = CALCULATE(COUNTROWS('tbl_Report'),'tbl_Report'[Return Status]="Non-return", ALLEXCEPT('tbl_Report',dim_Quarter[Quarter]))
VAR __count2 = CALCULATE(COUNT(tbl_Report[Return Status]),'tbl_Report'[Return Status] IN {"Return", "Nil return"},ALLEXCEPT('tbl_Report',dim_Quarter[Quarter]))
VAR __result = IF(ISBLANK(__count1) && NOT ISBLANK(__count2),CALCULATE(COUNT(tbl_Report[Return Status]),'tbl_Report'[Return Status]="Return") + 0)
RETURN
__result

vcgaomsft_0-1716792289660.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @vivians ,

Please try this measure:

N_complaint = 
VAR __count1 = CALCULATE(COUNTROWS('tbl_Report'),'tbl_Report'[Return Status]="Non-return", ALLEXCEPT('tbl_Report',dim_Quarter[Quarter]))
VAR __count2 = CALCULATE(COUNT(tbl_Report[Return Status]),'tbl_Report'[Return Status] IN {"Return", "Nil return"},ALLEXCEPT('tbl_Report',dim_Quarter[Quarter]))
VAR __result = IF(ISBLANK(__count1) && NOT ISBLANK(__count2),CALCULATE(COUNT(tbl_Report[Return Status]),'tbl_Report'[Return Status]="Return") + 0)
RETURN
__result

vcgaomsft_0-1716792289660.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

rajendraongole1
Super User
Super User

Hi @vivians - can you try the below measure to report only the available data upto Q3? and do a flag for measure for blank

 

N_complaints =
IF(
HASONEVALUE(tbl_report[Quarter]),
IF(
COUNTROWS(tbl_report) = 0,
BLANK(), -- If no rows, the quarter is "Non-return"
SUMX(
tbl_report,
IF(tbl_report[Return Status] = "Return", 1, 0)
)
),
BLANK()
)

 

add a flag measure also on the report

 

Regards,

Rajendra

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi, what do you mean by adding a flag measure on the report?

I've tried the new measure that you've suggested, but it is still not showing 0 for Q1 where it is a nil return (which means 0 complaint). 

Here is my test data: Report Test Data

Thanks again!

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors