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
akshay2204
Frequent Visitor

Group By and Summarize

Hi,

 

I need solution for the following .

 

I need a distinct count of customers who are relarted to the major group. When We ran a query in Sql we got the expected result. We are facing issue in creating the dax query for this. Please help me. 

akshay2204_0-1687612898462.png

 

Thanks in advance

 

3 REPLIES 3
akshay2204
Frequent Visitor

Hi @tamerj1  I checked this but still throwing an error for value conversion. Basically Year ID and Month ID will be used in slicers. we only need customer count and Major group

@akshay2204 

Calculated tables cannot interact with the filter context. This has to be a measure. In this case the year and moth slicers will filter the table automatically and no need to to be included in the dax filter. 

You need to create a MajorGroupCount table. This would be a single column disconnected table that includes integers ranging from 1 to the number of unique majour groups. Can be manually inserted or created using power query or dax. 
A dax exsmple would be

MajorGroupCount =

SELECTCOLUMN (
GENERATESERIES ( 1, DISTINCTCOUNT ( vwSalesData[MajorGroupID] ), 1 ),

"Count", [Value]
)

 

Place MajorGroupCount[Count] in a table visual along with the following measure 

CountMeasure =
SUMX (
VALUES ( MajorGroupCount[Count] ),
COUNTROWS (
FILTER (
SUMMARIZE (
vwSalesData,
vwSalesData[CustomerCode],
"MajorGroupCount", DISTINCTCOUNT ( vwSalesData[MajorGroupID] )
),
[MajorGroupCount] = MajorGroupCount[Count]
)
)
)

tamerj1
Super User
Super User

Hi @akshay2204 

please try

NewTable =
GROUPBY (
SUMMARIZE (
FILTER ( vwSalesData, vwSalesData[YearID] = 22 && vwSalesData[MonthID] = 4 ),
vwSalesData[CustomerCode],
"MajorGroupCount", DISTINCTCOUNT ( vwSalesData[MajorGroupID] )
),
[MajorGroupCount],
"#ofCustomers", COUNTX ( CURRENTGROUP (), 1 )
)

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.