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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Caculated column with Dax

Anis_Hussain_0-1680531406007.png

For this data set
I want to achieve for each StoreCode the Daily Sale is not blank and >0 for last 14 days then in Comparison column I want Yes else No.
Please help me writing this dax 

@freemanZ

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Comparison =
VAR CurrentDate = Sales[Retail Dates]
VAR CurrentStoreTable =
CALCULATETABLE ( Sales, ALLEXCEPT ( Sales, Sales[StoreCode] ) )
VAR Last14Days =
FILTER (
CurrentStoreTable,
Sales[Retail Dates] <= CurrentDate
&& Sales[Retail Dates] > CurrentDate - 14
)
VAR Last14DaysWithValue =
FILTER ( Last14Days, Sales[Daily Sale] > 0 )
RETURN
IF ( COUNTROWS ( Last14DaysWithValue ) = COUNTROWS ( Last14Days ), "Yes", "No" )

Wilson_
Super User
Super User

 

Hello Anis,

 

I am not FreemanZ, but hopefully my solution below is acceptable too. 😉 Let me know if the below calculated column works for you or if it is not what you're looking for.

 

Comparison = 
VAR CurrentDate = Table1[Retail Date]
VAR FilteredSales =
FILTER (
    Table1,
    DATEDIFF ( Table1[Retail Date], CurrentDate, DAY ) < 14 &&
    DATEDIFF ( Table1[Retail Date], CurrentDate, DAY ) >= 0
)
VAR Last14DaysSales =
SUMX (
    FilteredSales,
    Table1[Daily Sales]
)

RETURN
SWITCH (
    TRUE(),
    NOT ( ISBLANK ( Table1[Daily Sales] ) ) && Last14DaysSales > 0, "Yes",
   "No"
)

 

----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)




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

Proud to be a Super User!





Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.