The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello,
I am currently have an issue with count/countrows. When they evaluate and return nothing it shows blank instead of 0.
I have 2 tables, a calendar table and a fact table with 10 rows.
I am trying to calculate the percentage of colum ORIT = "Y".
Lines ORIT2 =
var _orit = CALCULATE(COUNTROWS(dataVN),dataVN[ORIT]="Y")
return if(ISBLANK(_orit),0,_orit)
The result is this. I don't want those extra lines that mean nothing.
The manufacturing data field comes from the calendar table.
How can I avoid this situation and get the desired result?
The .pbix file is in this link if you want to try - https://we.tl/t-bHGwtdUf5d
Thank you.
André
Solved! Go to Solution.
Hi @afbraga66
Please try https://www.dropbox.com/t/Fm7RwOsIaqz2Duog
Lines ORIT2 =
IF (
NOT ISEMPTY ( dataVN ),
COALESCE ( CALCULATE ( COUNTROWS ( dataVN ), dataVN[ORIT] = "Y" ), 0 )
)
CALCULATE(COUNTROWS(dataVN),dataVN[ORIT]="Y") + 0
Genius
This is by far the fastest and cleanest solution so far.
Hi @afbraga66
Please try https://www.dropbox.com/t/Fm7RwOsIaqz2Duog
Lines ORIT2 =
IF (
NOT ISEMPTY ( dataVN ),
COALESCE ( CALCULATE ( COUNTROWS ( dataVN ), dataVN[ORIT] = "Y" ), 0 )
)
HI @tamerj1 , It works thank you so much! Still, I'm intrigued on what is the role of ISEMPTY() and why without it, it doesn't work. Could you explain, please? Thank you.
If the table itself is empty in the current filter context then you need to keep the result blank. You need to have it zero if only the filtered table by CALCULATE is blank. Just pay attention to the difference between the original table and the filtered table.
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |