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
SravaniG
Helper I
Helper I

How to Calculate Distinct count of Products per store per Week

Hi,

I am very new to daxt. I am having requirement like, to calculte distinct count of products per store, per week. 

My query is showing same value for all the rows.

 

EVALUATE
SUMMARIZECOLUMNS (
    'Store'[StoreName],
    'Time'[Week],      
    TREATAS ( { "Store1", "Store2" }, 'Store'[StoreName] ),   
    TREATAS ({"P1","P2","P3","P4","P5","P6"},'Product'[Product Name] ),
    FILTER(VALUES('Time'[Week]),'Time'[Week]>="Week1" && 'Time'[Week]<="Week3"),
    "UnitS", [Units] ,
    "ProductCount", DISTINCTCOUNT('Product'[Product Name])   
)

Result:

  Sample.PNG

 

Expected Result should look like:

Expected.PNG

Could you please some one help me on this.

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@SravaniG , Try without unit

 

EVALUATE
SUMMARIZECOLUMNS (
'Store'[StoreName],
'Time'[Week],
TREATAS ( { "Store1", "Store2" }, 'Store'[StoreName] ),
TREATAS ({"P1","P2","P3","P4","P5","P6"},'Product'[Product Name] ),
FILTER(VALUES('Time'[Week]),'Time'[Week]>="Week1" && 'Time'[Week]<="Week3"),
"ProductCount", DISTINCTCOUNT('Product'[Product Name])
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @SravaniG ,

 

According to my understanding, you want to calculate the count of each store and each week,right?

Please create a new table and add a column using the following formula:

Table 2 =
DISTINCT ( SELECTCOLUMNS ( 'Table', "StoreName", [StoreName], "Week", [Week] ) )
Count =
VAR _st = [StoreName]
VAR _w = [Week]
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( 'Table', 'Table'[StoreName] = _st && 'Table'[Week] = _w )
    )

The final output is shown below:

3.1.5.count.PNG

Here is the pbix file.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@SravaniG , Try without unit

 

EVALUATE
SUMMARIZECOLUMNS (
'Store'[StoreName],
'Time'[Week],
TREATAS ( { "Store1", "Store2" }, 'Store'[StoreName] ),
TREATAS ({"P1","P2","P3","P4","P5","P6"},'Product'[Product Name] ),
FILTER(VALUES('Time'[Week]),'Time'[Week]>="Week1" && 'Time'[Week]<="Week3"),
"ProductCount", DISTINCTCOUNT('Product'[Product Name])
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors