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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

max value from last 14 days excluding weekends and holidays

Hi All,

 

johnbasha33_0-1610718607380.png

 

for 5/1/2019 the maximum value of the last 14 days is 425 not 422.25

I have tried many dax functions that is not coming.

 

kindly assist.

 

@amitchandak @Pragati11 @mwegener 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Need columns like this in date table

 

Work Day = if(WEEKDAY([Date],2)>=6,0,1)
Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])
Work Date Cont = if([Work Day]=0,maxx(FILTER('Date',[Date]<EARLIER([Date]) && [Work Day]<> EARLIER([Work Day]) ),[Date]),[Date])
Work Date cont Rank = RANKX(ALL('Date'),[Work Date Cont],,ASC,Dense)

 

 

a measure like

CALCULATE(Max('Table'[Value]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Work Date cont Rank])-14 && 'Date'[Week Rank]<=max('Date'[Work Date cont Rank])))

 

Traveling Across Workdays - What is next/previous Working day
https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calendar-4-5-Power/ba-p/1187766

View solution in original post

v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

First go to query editor>create an index column;

Then create a measure as below:

Measure = 
CALCULATE(MAX('Table'[Value.high]),FILTER(ALL('Table'),'Table'[Index]>=MAX('Table'[Index])-14&&'Table'[Value.tradingDay]<MAX('Table'[Value.tradingDay])))

And you will see:

v-kelly-msft_0-1610958843721.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

View solution in original post

4 REPLIES 4
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

First go to query editor>create an index column;

Then create a measure as below:

Measure = 
CALCULATE(MAX('Table'[Value.high]),FILTER(ALL('Table'),'Table'[Index]>=MAX('Table'[Index])-14&&'Table'[Value.tradingDay]<MAX('Table'[Value.tradingDay])))

And you will see:

v-kelly-msft_0-1610958843721.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

Anonymous
Not applicable

@v-kelly-msft  it works great thank you

amitchandak
Super User
Super User

@Anonymous , Need columns like this in date table

 

Work Day = if(WEEKDAY([Date],2)>=6,0,1)
Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])
Work Date Cont = if([Work Day]=0,maxx(FILTER('Date',[Date]<EARLIER([Date]) && [Work Day]<> EARLIER([Work Day]) ),[Date]),[Date])
Work Date cont Rank = RANKX(ALL('Date'),[Work Date Cont],,ASC,Dense)

 

 

a measure like

CALCULATE(Max('Table'[Value]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Work Date cont Rank])-14 && 'Date'[Week Rank]<=max('Date'[Work Date cont Rank])))

 

Traveling Across Workdays - What is next/previous Working day
https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calendar-4-5-Power/ba-p/1187766

Anonymous
Not applicable

@amitchandak  where is week rank column ?? it is missing from the measure

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.