Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi, i have a simple data model. Something like company name, income, expenses.
I created a custom measure Balance = income - expenses.
What I want to do is create a dynamic lable:
Finally, I want to have a number of companies by type.
I wrote a measure "Number of negative companies" = CALCULATE(DISTINCTCOUNT(data[CompanyName]);Balance<0) and I get an error saying "A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed."
What am I doing wrong?
Thank you!
You could do this:
Label = SWITCH(TRUE(), [Balance]<0,"negative", [Balance]>0,"positive", "zero" ) NegativeCount = VAR __table = SUMMARIZECOLUMNS('Table19'[Company],'table19',"__balance",[Balance]) RETURN COUNTX(FILTER(__table,[__balance]<0),[Company])
See attached Table 19, Page 11
Hi, Greg!
Thank you for your answer. I can't find the attached table.
Whoops, forgot to attach.
Thanks, I can see the file now.
This works when there are unique values for companies. In my table company name values are not unique.
Works for me. See updated attachment. Not sure why you would get different results. Perhaps share your sample data. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
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 |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |