cancel
Showing results for
Did you mean:

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Helper III

## Wrong metric count all

I need to calculate how many stores there are in total only if there are any units. I need to do it in a measure.
The stores with a value is 28 and the count all measure shows 35

1 ACCEPTED SOLUTION
Community Support

Hi, @krzysztof

You may create a measure as follows.

``````Count All =
COUNTROWS(
FILTER(
ALL('DWH Dimlocalization'),
'DWH Dimlocalization'[StoreID]<>BLANK()&&
'DWH Dimlocalization'[Units]<>BLANK()
)
)``````

Result:

Best Regards

Allan

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

6 REPLIES 6
Community Support

Hi, @krzysztof

You may create a measure as follows.

``````Count All =
COUNTROWS(
FILTER(
ALL('DWH Dimlocalization'),
'DWH Dimlocalization'[StoreID]<>BLANK()&&
'DWH Dimlocalization'[Units]<>BLANK()
)
)``````

Result:

Best Regards

Allan

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

Super User

Try

``````sumx(summarize((Table),Table[Store],"_sum",sum(table[unit])),If([_sum]>0,1,0))
//OR
sumx(summarize(all(Table),Table[Store],"_sum",sum(table[unit])),If([_sum]>0,1,0))``````

Helper III

@amitchandak @Mariusz @Anonymous Unfortunately, your proposals do not work. Below in the picture I present what I mean

Anonymous
Not applicable

So, you're asking for a calculated column, not a measure, right?

Result= IF(Units<> BLANK(), CALCULATE(COUNT('DWH DimLocalization'[StoreID]), FILTER(DWH DimLocalization, Units <> BLANK())), CALCULATE(COUNT('DWH DimLocalization'[StoreID])))

You'll put this column in your table as column. The result will be 35 for rows where Units = Blank(), 28 for rows where Units <> Blank()
Community Champion

Try this

``````Measure =
CALCULATE(
DISTINCTCOUNT( 'DWH DimLocalization'[StoreID] );
'DWH DimLocalization'[units] <> BLANK()
)``````

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.

Anonymous
Not applicable
Measure = CALCULATE(COUNT('DWH DimLocalization'[StoreID]), FILTER(DWH DimLocalization, StoreID <> BLANK()))