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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
KandiBawa
New Member

Divide the count of rows from one column with the count of non-blank rows from another column.

Hi All,

 

I have 2 columns that I want to use here:

1. Comments: This is a text column where people have either put in a comment or left it blank.

2. Sentiment: This is also a text column with 4 possible values (Positive, Negative, Neutral, and NA)

 

I want to get the % of each sentiment type for all the non-blank comments.
I.e. (Count of Sentiment Type/Non-Blank comments)*100

 

I have used the following measures:

 

1.  Total Comments = CALCULATE(COUNTROWS(Table1), Table1[Calendar Comments] <> BLANK())

On using this in a card visual it gives me the right value. I.e. 3675 non-blank comments.

 

2.  Dynamic Sem Sentiment = DIVIDE(COUNTROWS(Table1), 3675)

Using this when I have hard coded the denominator gives me the right result (see screenshot 1).

 

But if I update the measure to make it dynamic I.e 

Dynamic Sem Sentiment = DIVIDE(COUNTROWS(Table1), MeasureTable[Total Comments])
 
It gives me an incorrect result. (See screenshot 2)
 
Can you please explain why this is happening and how to fix this?
 
TIA
1.png2.png
3 REPLIES 3
sjoerdvn
Super User
Super User

If I understand the requirement correctly, it's like this:

Dynamic Sem Sentiment = DIVIDE(
	CALCULATE(COUNTROWS(Table1), Table1[Calendar Comments] <> BLANK())
	,CALCULATE(COUNTROWS(Table1),ALL(Table1[Sentiment]), Table1[Calendar Comments] <> BLANK())

)
v-rzhou-msft
Community Support
Community Support

Hi @KandiBawa ,

 

I think you can update [Total Comments] measure as below.

Total Comments =
CALCULATE (
    COUNTROWS ( Table1 ),
    FILTER ( ALLSELECTED ( Table1 ), Table1[Calendar Comments] <> BLANK () )
)

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BeaBF
Super User
Super User

@KandiBawa Hi! Try with a one single measure:

 

Dynamic Sem Sentiment =
VAR TotalNonBlankComments = CALCULATE(COUNTROWS(Table1), Table1[Calendar Comments] <> BLANK())
RETURN
DIVIDE(COUNTROWS(Table1), TotalNonBlankComments)

 

BBF

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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