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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Mikeysw
New Member

Count per group of summarizecolumns

Hi,

When using Summarizecolumns, I would like to get count of how manu times each child group appears.

 

For example, I have this DAX query

SUMMARIZECOLUMNS (
    'Date'[Calendar Year],
    'Product'[Color],
    "Amount", [Sales Amount],
    "Quantity",Sum(Sales[Quantity]))

 

I would like then to count the result and display how many times each color appears for each year.

 

I tried with groupby and currentgroup but I get double results as I have two measures.

 

Thank you!

Mike

2 REPLIES 2
Mikeysw
New Member

You are correct, thank you!

 

However my case is a bit more complicated as I have query with 3 dimensions (Continent/CountryRegion/City) part of paginated report. I would like to highlight only those child groups where there is 1 item.

So I need to get a count of items per each parent group. 

In this case, let's use different query, to be more exact.

EVALUATE
VAR __t1 =
SUMMARIZECOLUMNS (
Customer[Continent],
Customer[CountryRegion],
Customer[City],
"Amount", [Sales Amount]
)

RETURN
GROUPBY(
__t1,
Customer[Continent],
Customer[CountryRegion],
"Count" , countX(CURRENTGROUP(), Customer[CountryRegion] )
) ORDER BY Customer[Continent] DESC

 

Which brings me this

Mikeysw_0-1705410545342.png

Result I am looking for is

Mikeysw_1-1705410600524.png

 

And in a case where I have 3 dimensions
EVALUATE
VAR __t1 =
SUMMARIZECOLUMNS (
Customer[Continent],
Customer[CountryRegion],
Customer[City],
"Amount", [Sales Amount]
)

RETURN
GROUPBY(
__t1,
Customer[Continent],
Customer[CountryRegion],
Customer[City],
"Count" , countX(CURRENTGROUP(), Customer[City] )
) ORDER BY Customer[Continent] DESC

I get

Mikeysw_2-1705410779061.png

 

But I would like to see

Mikeysw_3-1705410796356.png

 

How should I approach this?
Thank you!

Fowmy
Super User
Super User

@Mikeysw 

You are grouping by Year and Color, then calculate two meaures so you should get each color appearing once. Here is the result:

EVALUATE
VAR __t1 =
SUMMARIZECOLUMNS (
    'Date'[Year],
    'Product'[Color],
    "Amount", [Sales Amount],
    "Quantity",Sum(Sales[Quantity])
)
 
 RETURN
 GROUPBY(
    __t1,
    'Date'[Year],
    'Product'[Color],
    "ColorCount" , SUMX(CURRENTGROUP(), 1 )
)

Fowmy_0-1705346728035.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.