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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors