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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.