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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.