Forum Discussion

Brady-Linnebur's avatar
2 years ago
Solved

Running Total Percentage based on day

Hello I need to get a measure/calculated column that does the following.   Here are the values: Monday = .09 aka 9% Tuesday = .11 Wednesday = .12 Thursday = .13 Friday = .18 Saturday = .19 S...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Brady-Linnebur ,

     

    You can refer to my test file to learn more details. Here I start my week on Wednesday, you can change the _SELECTSTART part in my code to change the start day.

    DimDate = 
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2024, 01, 01 ), DATE ( 2024, 12, 31 ) ),
        "Year", YEAR ( [Date] ),
        "Month", MONTH ( [Date] ),
        "MonthName", FORMAT ( [Date], "MMMM" ),
        "WeekDay", WEEKDAY ( [Date], 2 ),
        "WeekDayName", FORMAT ( [Date], "DDDD" )
    )
    FY Week Start = 
    VAR _SELECTSTART = 3
    RETURN
    IF(DimDate[WeekDay]>=3, DimDate[Date] - [WeekDay] +_SELECTSTART, DimDate[Date] - [WeekDay] - _SELECTSTART - 1)
    FY WeekDay = 
    VAR _SELECTSTART = 3
    RETURN
    IF(DimDate[WeekDay]>=_SELECTSTART,DimDate[WeekDay] - _SELECTSTART +1, DimDate[WeekDay] + 7 - _SELECTSTART + 1)

    Measures:

    FY WeekDay = 
    VAR _SELECTSTART = 3
    RETURN
    IF(DimDate[WeekDay]>=_SELECTSTART,DimDate[WeekDay] - _SELECTSTART +1, DimDate[WeekDay] + 7 - _SELECTSTART + 1)
    Running Total = 
     SUMX(FILTER(ALLSELECTED(DimDate),DimDate[Date]<=MAX(DimDate[Date])),[Percentage])
    Filter = 
    IF(MAX(DimDate[Date])<=TODAY() && MAX(DimDate[FY Week Start]) = CALCULATE(MAX(DimDate[FY Week Start]),FILTER(ALLSELECTED(DimDate),DimDate[Date] = TODAY())),1,0)

    Result is as below.

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.