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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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])
)

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
v-eqin-msft
Community Support
Community Support

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])
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors