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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.