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
Anonymous
Not applicable

Comparison works weird

The model contains of two tables/entities (note the terms are terms from the model, not from power BI itself):
- indicator
- data source

"indicator" is linked to "data source" as one-to-many: multiple data sources might be needed for a certain indicator. Each "data source" has a status - wherever it has or has not data model designed.

 

"data source" has following measures defined:
- total sources (=DISTINCTCOUNT(sources[ID]))

- format-ready sources (=CALCULATE(DISTINCTCOUNT(sources[ID]); sources[status] IN {"ModelReady"})
- % of format-ready sources (=sources[format-ready sources]/sources[total sources])

Now we need to tell wherever an "indicator" is format-ready or not. Obviously, it is ready when all of its data sources are ready, in other words, when '% of format-ready sources' measure equals to 100%.

So we use the formula within "indicator" table: IsDataReady = (sources[% of format-ready sources] = 1)

The problem:
- if we define a CALCULATED COLUMN with this formula, it does not work (returns incorrect false values)
- if we defined a MEASURE with exactly the same formula, it works as expected

Why we see this as a problem: from the business prospective, the attribute defining wherever a certain indicator is data-ready or not is not a measure over the range of indicators, it is and should be exactly the calculated attribute of an indicator; any aggregations can not and should not be applied to it. It's not a measure. It must be a calculated column - but it does not work being a calculated column.

Any ideas?

8 REPLIES 8
Anonymous
Not applicable

// Don't use floating-point arithmetic if you don't have to. It's inaccurate by nature so
// equality should never be performed on such numbers.
 
// And here's your column:

[IsDataReady] = // calculated column in indicator
var __allSources = RELATEDTABLE( 'sources' )
var __allSourcesCount = COUNTROWS( __allSources )
var __readySources =
	filter(
		__allSources,
		sources[status] = "ModelReady"
	)
var __readySourcesCount =
	COUNTROWS( __readySources )
RETURN
	__readySourcesCount = __allSources

Best

D

Anonymous
Not applicable

After replacing a typo in the last row __readySourcesCount = __allSourcesCount and using actual table/column names, the result is again incorrect.

 

Also the issue is not related to decimal vs. whole number comparison as it evaluates to false (for calculated column) even for rows where e.g. total sources = 1, format ready sources = 1 and there is a 1/1 division before comparing to 1

See the screenshot

 

Capture.JPG

Anonymous
Not applicable

Why don't you do

[IsFormatReady] = ([Total Sources] = [format-ready sources] ?

This should give you exactly what you need....

Best
D
Anonymous
Not applicable

Using this [IsFormatReady] = ([Total Sources] = [format-ready sources]) provides exactly the same results:
- it works correct if formula is used as a definition of a measure

- it doesn't work if the same formula is used as a definition of a calculated column

Anonymous
Not applicable

It's also possible that you are not following best practices... and hence the problems.

Best
D
Anonymous
Not applicable

"you are not following best practices"

 

Not following what exactly?

Anonymous
Not applicable

The principles of dimensional design. Too much to talk about.

I can assure you 100% that If you have a dimension with unique members and this dimension is connected 1:* to a fact table and you have 2 measures, [A] and [B], that work correctly for each and every member of the dimension, then a calc column of the form ([A] = [B]) must OUT OF NECESSITY return the correct result.

If it does not, then there must be something wrong with the model.

Best
D
Anonymous
Not applicable

First, the formula is not a measure. It's a calculated column formula. Second, I don't know your model's structure and data. Probably you have to make sure that you count distinct 'something' in source.

It looks like you're trying to use it in a visual as a measure... I'm confused.

Best
D

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.