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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
krzysztof
Helper III
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

 

Count ALL.png

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @krzysztof 

 

Based on your description, I created data to reproduce your scenario.

c1.png

 

You may create a measure as follows.

 

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

 

 

Result:

 

c2.png

 

Best Regards

Allan

 

 

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

View solution in original post

6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hi, @krzysztof 

 

Based on your description, I created data to reproduce your scenario.

c1.png

 

You may create a measure as follows.

 

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

 

 

Result:

 

c2.png

 

Best Regards

Allan

 

 

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

amitchandak
Super User
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))

 

 

Appreciate your Kudos.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

 

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()
Mariusz
Community Champion
Community Champion

Hi @krzysztof 

 

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.
LinkedIn


 

Anonymous
Not applicable

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.