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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Gerbil
Helper I
Helper I

Creating a Card that displays a count of aggregate data?

Reposting this with clearer table

 

So I have a table like so:

 

Region     Name     Flag     Count of Job ID
NorthJohnOn12
SouthDrakeOff11
SouthJasonOn5
WestKendallOff9
SouthJennyOff13
EastSamOn8

 

 

The last column is a count of Job ID, which is a text type column. As an example, there are 12 Job ID entries with region North, name John, and flag On. I want a card that shows the number of entries that are "Off" and have a count higher than 10.

 

The preferred outcome would be a card displaying 2 since there are two rows that fit those criteria. How would I go about doing that?

1 ACCEPTED SOLUTION

Try this:
 
rowcount =
VAR table1 = CALCULATETABLE(SUMMARIZE('Table', 'Table'[Flag], 'Table'[Region], 'Table'[Name], "@rowcount", COUNTROWS('Table')), 'Table'[Flag] = "Off")
RETURN
COALESCE(SUMX(table1, IF([@rowcount] > 10, 1, 0)), 0)
 
 
///Mediocre Power BI Advice, but it's free///

View solution in original post

4 REPLIES 4
kpost
Super User
Super User

I started with the table you provided, exactly as you typed it, with [Count of Job ID] being datatype text.
 
Here's the measure:
 
Row_Count =
CALCULATE(COUNTROWS('Table'), 'Table'[Flag] = "Off", VALUE('Table'[Count of Job ID]) > 10)

 

And voila:

 

result.PNG

 

See attached .pbix file

 

So the data coming in (from direct query) looks like this:

 

Region          Name          Flag          Job ID     
NorthJohnOn16127
NorthJohnOn77647
NorthJohnOn41588
NorthJohnOn46424
NorthJohnOn24132
NorthJohnOn56180
NorthJohnOn57396
NorthJohnOn41324
NorthJohnOn8899
NorthJohnOn809
NorthJohnOn19558
NorthJohnOn91024
NorthJohnOn90642
SouthDrakeOff52577
SouthDrakeOff76784
SouthDrakeOff81416
SouthDrakeOff77264
SouthDrakeOff53032
SouthDrakeOff25992
SouthDrakeOff50560
SouthDrakeOff20368
SouthDrakeOff81093
SouthDrakeOff97126
SouthDrakeOff46680
SouthDrakeOff59402
SouthJasonOn93735
SouthJasonOn24804
SouthJasonOn8312
SouthJasonOn96618
SouthJasonOn5066

...etc

 

And the table created above has the column "Count of Job ID" through Power BI. "Count of Job ID" is not an actual column, it's more like a measure. It's an aggregate count of "Job ID". So I can't use the function you've provided since "Count of Job ID" is not a column in my table.

Try this:
 
rowcount =
VAR table1 = CALCULATETABLE(SUMMARIZE('Table', 'Table'[Flag], 'Table'[Region], 'Table'[Name], "@rowcount", COUNTROWS('Table')), 'Table'[Flag] = "Off")
RETURN
COALESCE(SUMX(table1, IF([@rowcount] > 10, 1, 0)), 0)
 
 
///Mediocre Power BI Advice, but it's free///

That totally worked! Thank you so much!

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.