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