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
tsimon21
New Member

Powerbi formula Issue

Total Volume / Day - Combined vs Last 4 Days of Week - % =
DIVIDE([Total Volume - Combined - Last Date]
 - [Total Volume / Day - Combined - Last 4 Days of Week], [Total Volume / Day - Combined - Last 4 Days of Week], 0)
 
I am trying to get this forula to work for viewing yesterday's date vs the prior 4 same days in prior 4 weeks. For example this Friday vs the previous 4 fridays. I am trying to see how the day is trending vs prior weeks, but the data consistently comes back blank. I believe the issue lies with the date filtering.
1 ACCEPTED SOLUTION

Hi @tsimon21 ,

 

Create calculated colunm and modify formual like below:

week = WEEKDAY('Table'[Date],2)
result_ =
VAR cur_ =
    CALCULATE (
        SUM ( 'Table'[Total Volume] ),
        DATESBETWEEN ( 'Table'[Date], TODAY (), TODAY () )
    )
VAR sel_ =
    SELECTEDVALUE ( slicer[Week] )
VAR week_ =
    WEEKDAY ( TODAY () - sel_, 2 )
VAR last_sel_week =
    CALCULATE (
        SUM ( 'Table'[Total Volume] ),
        DATESBETWEEN ( 'Table'[Date], TODAY () - sel_, TODAY () - sel_ ),
        FILTER ( 'Table', 'Table'[week] = week_ )
    )
RETURN
    DIVIDE ( cur_ - last_sel_week, last_sel_week )

vkongfanfmsft_0-1711618229273.png

 

 

Best Regards,
Adamk Kong

 

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

View solution in original post

5 REPLIES 5
v-kongfanf-msft
Community Support
Community Support

Hi @tsimon21 ,

 

Thanks for the reply from @lbendlin , please allow me to provide another insight.

 

You need to use the date function correctly, refer to the following formula:

result_ =
VAR cur_ =
    CALCULATE (
        SUM ( 'Table'[Total Volume] ),
        DATESBETWEEN ( 'Table'[Date], TODAY (), TODAY () )
    )
VAR sel_ =
    SELECTEDVALUE ( slicer[Week] )
VAR last_sel_week =
    CALCULATE (
        SUM ( 'Table'[Total Volume] ),
        DATESBETWEEN ( 'Table'[Date], TODAY () - sel_, TODAY () - sel_ )
    )
RETURN
    DIVIDE ( cur_ - last_sel_week, last_sel_week )

 

vkongfanfmsft_0-1711531788219.png

 

Best Regards,
Adamk Kong

 

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

 

 

This gets me close, but I can only view vs 1 prior week. I need the combined past 4 fridays vs the current. For example: 3/22 compared to Average of (3/15, 3/8, 3/1, 2/23), and this needs to be dynamic so it moves with each new day

Hi @tsimon21 ,

 

Create calculated colunm and modify formual like below:

week = WEEKDAY('Table'[Date],2)
result_ =
VAR cur_ =
    CALCULATE (
        SUM ( 'Table'[Total Volume] ),
        DATESBETWEEN ( 'Table'[Date], TODAY (), TODAY () )
    )
VAR sel_ =
    SELECTEDVALUE ( slicer[Week] )
VAR week_ =
    WEEKDAY ( TODAY () - sel_, 2 )
VAR last_sel_week =
    CALCULATE (
        SUM ( 'Table'[Total Volume] ),
        DATESBETWEEN ( 'Table'[Date], TODAY () - sel_, TODAY () - sel_ ),
        FILTER ( 'Table', 'Table'[week] = week_ )
    )
RETURN
    DIVIDE ( cur_ - last_sel_week, last_sel_week )

vkongfanfmsft_0-1711618229273.png

 

 

Best Regards,
Adamk Kong

 

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

stg_Day_of_Week =
SELECTCOLUMNS(
FILTER(dim_Calendar,
dim_Calendar[Date] > TODAY() - 31 && dim_Calendar[Date] < TODAY() - 6 &&
dim_Calendar[day of week] = FORMAT ( TODAY() - 1, "ddd" )),
"Date", dim_Calendar[Date], "day of week", dim_Calendar[day of week]) current formula that is coming back as Scalar
lbendlin
Super User
Super User

I don't see in your formula where you subtract 1,8,15,22,29 from TODAY().

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.

Top Solution Authors