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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Optimize Countrows - GroupBy

Hi everyone!

 

I want to optimize a measure that I´ve calculated but I´m getting trouble trying to get the same result with different coding approaches.

 

In my data model I have something like this:

 

Fact_Table connected to Product dimension, to Time dim, Customer dim, Stores dim.

 

I want to calculate how many unique products I have in the combination Customer - Stores. 

Example:

 

Customer A

-Store A: 4 unique products.

-Store B: 6 unique products.

 

Customer B

-Store 01: 10 unique products.

-Store 02: 4 unique products.

 

When adding in a Table visual Customer Name + Measure I should see:

Customer A: 10 

Customer B: 14

 

I´ve managed to get this result doing this but performance sucks 😞

 

COUNTROWS(
    GROUPBY (
        Fact_Table,
        'Customer'[Customer Name],
        'Store'[Store Name],
        'Product'[Item ID]
)
)
1 REPLY 1
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous ,

Could you please post some simple sample data and your desired result to have a test if possible? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors
Top Kudoed Authors