Forum Discussion

bansheeboyb's avatar
bansheeboyb
Regular Visitor
6 years ago
Solved

Combining weekend margin with Friday.

I am trying to get Saturday and Sundays margin to be added into the previous Friday.   It is a very simple table and everything.  I have the ship date, margin, and day number. Everything I have tri...
  • DataZoe's avatar
    6 years ago

    Hi, this measure should give you what you want, the hasonevalue will also make it so it totals correctly too.

     

    Margin Roll Into Friday =
    VAR _margin =
    SUM ( 'RollIntoFriday'[Margin] )
    RETURN
    IF (
    HASONEVALUE ( RollIntoFriday[Ship Date] ),
    SUMX (
    VALUES ( 'RollIntoFriday'[Ship Date] ),
    IF (
    WEEKDAY ( 'RollIntoFriday'[Ship Date] ) = 6,
    _margin
    + CALCULATE (
    SUM ( 'RollIntoFriday'[Margin] ),
    NEXTDAY ( RollIntoFriday[Ship Date] )
    )
    + CALCULATE (
    SUM ( 'RollIntoFriday'[Margin] ),
    NEXTDAY ( NEXTDAY ( RollIntoFriday[Ship Date] ) )
    ),
    IF ( WEEKDAY ( 'RollIntoFriday'[Ship Date] ) IN { 1, 7 }, BLANK (), _margin )
    )
    ),
    _margin
    )