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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to get previous date from fact table if max date is weekend in power bi

HI Team

can you please let me know i just need to sum of Total Length as per max date and Previous date

SPTotal LengthDate
A18/07/2021
B28/07/2021
C38/07/2021
A49/07/2021
B59/07/2021
C69/07/2021
A712/07/2021
B812/07/2021
C912/07/2021

 

Like if I use max(Date)-1 it shows 11/7/21 which is weekend then it should select 9/7/21 for filtering.

I am using this meassure

Previous_Total_Length =
CALCULATE(
[TTD],
FILTER(ALL(Sheet1[Download Date]),
Sheet1[Download Date]= MAX(Sheet1[Download Date])-3
)
)

so if MAX(Sheet1[Download Date])-1 is weekend then i have to do -3 and if not then -1. but i dont want manually change -3 and -1. 

can anyone help me out.

heaps thanks

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You asked a question in Power Query, but you need a DAX measure, right? Is your Sheet1 the same fact table as your sample data? Try to identify weekday first

Previous_Total_Length =
VAR CurDate =
    MAX ( Sheet1[Download Date] )
VAR CurDay =
    WEEKDAY ( CurDate, 2 )
VAR PreDate =
    SWITCH (
        TRUE (),
        CurDay = 1, CurDate - 3,
        CurDay = 7, CurDate - 2,
        CurDate - 1
    )
RETURN
    CALCULATE (
        [TTD],
        FILTER ( ALL ( Sheet1[Download Date] ), Sheet1[Download Date] = PreDate )
    )

 

View solution in original post

2 REPLIES 2
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You asked a question in Power Query, but you need a DAX measure, right? Is your Sheet1 the same fact table as your sample data? Try to identify weekday first

Previous_Total_Length =
VAR CurDate =
    MAX ( Sheet1[Download Date] )
VAR CurDay =
    WEEKDAY ( CurDate, 2 )
VAR PreDate =
    SWITCH (
        TRUE (),
        CurDay = 1, CurDate - 3,
        CurDay = 7, CurDate - 2,
        CurDate - 1
    )
RETURN
    CALCULATE (
        [TTD],
        FILTER ( ALL ( Sheet1[Download Date] ), Sheet1[Download Date] = PreDate )
    )

 

Anonymous
Not applicable

HI Vera_33, I really appriciate your  support. to get this to be done I strugged a lot. now get sorted. Heaps thanks

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors