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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Count Function or Any other Function

Hi,

 

Below is the table in which I want to count number of Units in a building using a measure if possible. 

 

Building IDUnit Type
101L1
101L2
101L3
101L4
101L5
101L6
101L7
102L1
102L2
102L3
102L4
102L5

 

 

And I want the measure to count as below :

 

Building IDNo. of Unit
1017
1025
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @Anonymous ,

Please try to create a measure with below dax formula:

No.of Unit =
VAR _id =
    SELECTEDVALUE ( 'Table'[Building ID] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [Building ID] = _id )
VAR _val =
    CALCULATE ( COUNT ( 'Table'[Unit Type] ), tmp )
RETURN
    _val

vbinbinyumsft_0-1683785257025.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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

2 REPLIES 2
v-binbinyu-msft
Community Support
Community Support

Hi @Anonymous ,

Please try to create a measure with below dax formula:

No.of Unit =
VAR _id =
    SELECTEDVALUE ( 'Table'[Building ID] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [Building ID] = _id )
VAR _val =
    CALCULATE ( COUNT ( 'Table'[Unit Type] ), tmp )
RETURN
    _val

vbinbinyumsft_0-1683785257025.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Mahesh0016
Super User
Super User

@Anonymous 
No. of Unit = COUNT(Table[Unit Type])
#####################################
No. of Unit 1 =
calculate([No. of Unit],ALLEXCEPTE(TableName,Table[Building ID]))

 

################################################

No. of Unit 2 =
calculate(COUNT(Table[Unit Type]),ALLEXCEPTE(TableName,Table[Building ID]))

 

 

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.