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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
tina345
Helper II
Helper II

Creating a card using sql query

Hello Experts,

  I have a data like below which is from a database sql query.

  I need to use a card to display counts for each code (A,B in this case) in this query.

  What is the best approach to display counts on cards?

 

 Do I need to create separate measure for each code and use rowcount with filter using code? Or  we have something so that we don't need to create measure for each code (A,B)?

 

 

Code,Value,Date

------------------

A, 1, 7/1/2021

A,2, 7/2/2021

B,5,6/1/2021

B,6,7/2/2021

B,7,7/3/2021

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @tina345 

Solution1:
Create  separate measure for each code and put them to card visual

CountA = 
CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[Code] = "A" ) )
CountB = 
CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Code]="B") )

Solution2:

Put field "Value" to card visual and then change the aggregation from "Sum" to "Count".

Put field "Code" to visual filter pane and select "Basic filtering" to filter data you want.

11.png

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

 

 

View solution in original post

1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @tina345 

Solution1:
Create  separate measure for each code and put them to card visual

CountA = 
CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[Code] = "A" ) )
CountB = 
CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Code]="B") )

Solution2:

Put field "Value" to card visual and then change the aggregation from "Sum" to "Count".

Put field "Code" to visual filter pane and select "Basic filtering" to filter data you want.

11.png

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

 

 

Helpful resources

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

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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