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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Vaishali04
Helper III
Helper III

Count rows of UI table and show in card at UI

Hi All,

 

I have created below table at UI. Created to measures (Measure1 & Measure 2) using What If parameter. In Primary/Secoundary column I am assigning value on comparing  Measure1 & Measure 2. So I can't replicated the measures as calculated column.

If Measure1 < Measure 2 than Primary else Secoundary

 

My requirement is to show count of Primary/Secoundarys column in card at UI. So count will come as 2 Primary and 1 Secoundary in individal data cards.

 

ResourceTypeIDMeasure1Measure2Primary/Secoundary
abcActive14567Primary
edActive28945Secoundary
xyzPassive32199Primary

 

If anyone has come across with same scenarieo then please advice how to display the data.

 

Regards

Vaishali

1 ACCEPTED SOLUTION

Hi @Vaishali04 

 

Create a variable table in the DAX measure and then you can use count() function in it. 

Try measures like: 

 

Primary Count = 
VAR _table = SELECTCOLUMNS('Table',"Resource",'Table'[Resource],"Type",'Table'[Type],"ID",'Table'[ID],"Primary/Secondary",[Primary/Secondary])
VAR _countPrimary = COUNTROWS(FILTER(_table,[Primary/Secondary]="Primary"))
RETURN
_countPrimary


Secondary Count = 
VAR _table = SELECTCOLUMNS('Table',"Resource",'Table'[Resource],"Type",'Table'[Type],"ID",'Table'[ID],"Primary/Secondary",[Primary/Secondary])
VAR _countPrimary = COUNTROWS(FILTER(_table,[Primary/Secondary]="Secondary"))
RETURN
_countPrimary

 

 Test result:

10234.jpg

Best Regards,

Community Support Team _ Jing Zhang

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

View solution in original post

3 REPLIES 3
Anand24
Super User
Super User

Hi @Vaishali04 ,

 

Can you try the below dax in calculated measure and pull it in Card:

 

For Primary Count:

Primary Count = CALCULATE(COUNT('TableName'[Primary/Secondary]), FILTER(TableName ,MAX(TableName[Primary/Secondary])="Primary")

For Secondary Count:

Secondary Count = CALCULATE(COUNT('TableName'[Primary/Secondary]), FILTER(TableName ,MAX(TableName[Primary/Secondary])="Secondary ")

 

Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!

 

Hi @Anand24 

 

Primary/Secondary column in the table is a measure not a column in table 'TableName'[Primary/Secondary]). So Count(Primary/Secondary) is not valid statement.

Hi @Vaishali04 

 

Create a variable table in the DAX measure and then you can use count() function in it. 

Try measures like: 

 

Primary Count = 
VAR _table = SELECTCOLUMNS('Table',"Resource",'Table'[Resource],"Type",'Table'[Type],"ID",'Table'[ID],"Primary/Secondary",[Primary/Secondary])
VAR _countPrimary = COUNTROWS(FILTER(_table,[Primary/Secondary]="Primary"))
RETURN
_countPrimary


Secondary Count = 
VAR _table = SELECTCOLUMNS('Table',"Resource",'Table'[Resource],"Type",'Table'[Type],"ID",'Table'[ID],"Primary/Secondary",[Primary/Secondary])
VAR _countPrimary = COUNTROWS(FILTER(_table,[Primary/Secondary]="Secondary"))
RETURN
_countPrimary

 

 Test result:

10234.jpg

Best Regards,

Community Support Team _ Jing Zhang

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

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.