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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Julien74
Frequent Visitor

Group by calculation

Hi, 

 

I have a table like that (with text Id)

 

Julien74_0-1666276051673.png

 

 

and I want to obtain a group by like that which sum is distinct number of Id by departement 

 

Julien74_1-1666276061400.png

 

Thank you

Julien 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Julien74 ,

 

Please try:

New Table =
SUMMARIZE (
    'Table',
    'Table'[Serivice],
    'Table'[Date],
    "Month", FORMAT ( 'Table'[Date], "mmmm" ),
    "Count", DISTINCTCOUNT ( 'Table'[ID] )
)

Since measure only return scalar, you must introduce entity columns to group data. Similarly, if you want a measure, you need to create a calculated column in the original table.

Month = FORMAT('Table'[Date],"mmmm")

Then new a meaure:

Count = DISTINCTCOUNT('Table'[ID])

Then use [Count],'Table'[Month] and 'Table'[Serivice] in a table visual.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

5 REPLIES 5
Shaurya
Memorable Member
Memorable Member

Hi @Julien74,

 

Use the following DAX Code:

 

New Table = SUMMARIZE('Table', 'Table'[Service], "Month",MONTH('Table'[Date], "Count",DISTINCTCOUNT('Table'[ID]))

 

Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: How to Export Telemetry Data from Azure IoT Central into Power BI

Hi @Shaurya 

 

I'm sorry but i can't find 'Table'[Date] (but date is in my table)  in your formula and the month function accept only one argument. 

Hi @Julien74,

 

'Table'[Date] is simply the name of the table and date column in your model. About the month paramter, I missed a bracket.

 

New Table = SUMMARIZE('Table', 'Table'[Service],
"Month", MONTH('Table'[Date]),
"Count", DISTINCTCOUNT('Table'[ID]))

 

Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: Forecast Period - Previous Forecasts

Hi thanks for your answer. I understand well it's the column on my model. But it says thats is impossible to determine a unique value for my column "date" 

Anonymous
Not applicable

Hi @Julien74 ,

 

Please try:

New Table =
SUMMARIZE (
    'Table',
    'Table'[Serivice],
    'Table'[Date],
    "Month", FORMAT ( 'Table'[Date], "mmmm" ),
    "Count", DISTINCTCOUNT ( 'Table'[ID] )
)

Since measure only return scalar, you must introduce entity columns to group data. Similarly, if you want a measure, you need to create a calculated column in the original table.

Month = FORMAT('Table'[Date],"mmmm")

Then new a meaure:

Count = DISTINCTCOUNT('Table'[ID])

Then use [Count],'Table'[Month] and 'Table'[Serivice] in a table visual.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.