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
bansheeboyb
Regular Visitor

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 tried so far has failed, Any suggestions?

 

 

Capture.PNG

1 ACCEPTED SOLUTION
DataZoe
Employee
Employee

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
)

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

4 REPLIES 4
DataZoe
Employee
Employee

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
)

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Hey, Thanks for trying to help me out with this.

 

I tried that measure, but it doesnt seem to work. Here is an iamge that shows what I get from it. 

 

Any ideas?Capture.PNG

From what you showed, it looks like the nextday() is not working properly. (https://docs.microsoft.com/en-us/dax/nextday-function-dax ).

 

Is ship date set as a date column? If it's in a dim date table, also make sure the table is set as date table. If it's not in a dim date table, the auto date/time intelligence should be on (it's on by default). Also make sure your power bi desktop is on the latest version (Version: 2.79.5768.1082 64-bit (March 2020)) just to cover all the bases!

 

I was able to get it to work with [Ship Date] being a date column:

 

RollIntoFriday.JPG

 

I also included PBIX file here: https://github.com/DataZoe/PBIX/blob/master/RollIntoFridayExample.pbix 

 

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Sweet, instead of using the ship date in the query that was pulling the information, I used the master date dimension table I created to tie all my queries together and now it works perfectly.

 

Thanks again!

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.