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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Avinash19
Regular Visitor

sales in last 3 days filtering on store and product level

Hi,

 

Need an help with below query

 

I want to calculate last 3 days sales of a product in a particular store, so if there is a sale in last 3 days then it will display result as 1 but if there is no sale in last 3 days then result should be 0.

 

STORE

---------

date     product_id  store_id  cnt_txns
08/04/2440514911
09/04/24408804911
10/04/24408804911
11/04/24408804911

 

OUTPUT

---------

date     product_id    store_id   last 3  days txns
12/04/2440514910 (no sale on 9th,10,11)
12/04/24408804911 (there was a sale in past 3 days)

 

can someone please help me with the dax here?

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Avinash19 

pls try this

 

Column =
VAR _count=CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[  product_id]='Table (2)'[  product_id]&&'Table'[  store_id]='Table (2)'[    store_id]&&'Table'[date   ]<'Table (2)'[date   ]&&'Table'[date   ]>='Table (2)'[date   ]-3))
return if(_count>=1,1,0)
 
11.png
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ryan_mayu
Super User
Super User

@Avinash19 

pls try this

 

Column =
VAR _count=CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[  product_id]='Table (2)'[  product_id]&&'Table'[  store_id]='Table (2)'[    store_id]&&'Table'[date   ]<'Table (2)'[date   ]&&'Table'[date   ]>='Table (2)'[date   ]-3))
return if(_count>=1,1,0)
 
11.png
 
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.