Hello @hunghahuy,
Thank You for posting your query onto the Forum.
While my colleague @AntrikshSharma has already posted a solution, I just wanted to share my solution.
I’ve worked it in couple of ways i.e., one solution is in the form of “Total Transactions In First 7 Days (In Terms of Products Count)” whereas the other one is in the form of “Total Transactions In First 7 Days (In Terms of Products Names)”. Below are both the DAX measures alongwith the screenshot of the final results provided for the reference -
Products In First 7 Days - Product Count =
SUMX(
ADDCOLUMNS(
FILTER(
SUMMARIZE(
'Sales Orders' ,
'Sales Orders'[OrderDate] ,
Dates[Date] ,
Customers[Customer Names] ,
Products[Product Name] ) ,
Dates[Date] >=
CALCULATE( MIN( 'Sales Orders'[OrderDate] ) ,
ALLEXCEPT( 'Sales Orders' , Customers[Customer Names] ) ) &&
Dates[Date] <=
CALCULATE( MIN( 'Sales Orders'[OrderDate] ) ,
ALLEXCEPT( 'Sales Orders' , Customers[Customer Names] ) ) + 7 ) ,
"@Product_Name" ,
1 ) ,
[@Product_Name] )
Products In First 7 Days - Product Names =
IF( ISINSCOPE( Customers[Customer Names] ) ,
CONCATENATEX(
TOPN(
15 ,
ADDCOLUMNS(
FILTER(
SUMMARIZE(
'Sales Orders' ,
'Sales Orders'[OrderDate] ,
Dates[Date] ,
Customers[Customer Names] ,
Products[Product Name] ) ,
VAR _Min_Date =
CALCULATE( MIN( 'Sales Orders'[OrderDate] ) ,
ALLEXCEPT( 'Sales Orders' , Customers[Customer Names] ) )
RETURN
Dates[Date] >= _Min_Date &&
Dates[Date] <= _Min_Date + 7 ) ,
"@Product_Name" ,
CALCULATE( MIN( Products[Product Name] ) ) ) ,
[@Product_Name] ,
ASC ) ,
Products[Product Name] ,
" , " ) ,
BLANK() )
I’m also attaching the working of the PBIX file for the reference purposes.
Hoping you find this helpful.
Important Note: In your case, the figure for “Total Transactions for First 7 Days” is showcasing as 67 whereas the actual number of records for those transactions is 104.
Thanks and Warm Regards,
Harsh
Total Transactions In First 7 Days - Harsh.pbix (454.5 KB)