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
slavisha84
Helper I
Helper I

How to calculate Revenue for each day of Current Fiscal Week for this and last year?

Hello,
I have two tables, FiscalCalendar, and Revenue by date.
I am trying to create a breakdown by day for the current fiscal week of this year, and the same period for the last year. 
My FiscalCalendar table looks like this:

slavisha84_0-1618537999087.png


MyRevenueByDate table looks like this:

slavisha84_1-1618538073004.png


What I need to produce is Matrix or table that looks like this:

slavisha84_3-1618539076069.png

So this is specific for the current fiscal week which is 14.
GrowthPerDay is just a simple formula (this year - last year)/ last year. 
WeekToDate would be, for example, (Monday and Tuesday together for fiscal week 14 of this week) - Monday and Tuesday together for fiscal week 14 last Year) / (Monday and Tuesday together for fiscal week 14 of last year)
In Excel, this is pretty easy to produce with a pivot table and lookup formula but can this be done in DAX?
How would I create a view like this?


Here is the folder where I have a sample of data with .pbix file :
https://1drv.ms/u/s!AhhZq1add5YwjYIvuASi76lCL3R1eA?e=sZQshq

 



 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @slavisha84 

You could create below measures and put them in a table.

 

Revenue This Year = SUM(RevenueByDate[Revenue])


Revenue Last Year = CALCULATE(SUM(RevenueByDate[Revenue]),FILTER(ALL(FiscalCalendar[FiscalYear]),FiscalCalendar[FiscalYear]=SELECTEDVALUE(FiscalCalendar[FiscalYear])-1))


GrowthPerDay = DIVIDE(RevenueByDate[Revenue This Year]-[Revenue Last Year],[Revenue Last Year])


WeekToDateGrowth =
VAR thisYearValue =
    CALCULATE (
        SUM ( RevenueByDate[Revenue] ),
        FILTER (
            ALL ( FiscalCalendar ),
            FiscalCalendar[FiscalYear] = SELECTEDVALUE ( FiscalCalendar[FiscalYear] )
                && FiscalCalendar[FiscalWeek] = SELECTEDVALUE ( FiscalCalendar[FiscalWeek] )
                && FiscalCalendar[Date] <= MAX ( FiscalCalendar[Date] )
        )
    )
VAR lastYearValue =
    CALCULATE (
        SUM ( RevenueByDate[Revenue] ),
        FILTER (
            ALL ( FiscalCalendar ),
            FiscalCalendar[FiscalYear]
                = SELECTEDVALUE ( FiscalCalendar[FiscalYear] ) - 1
                && FiscalCalendar[FiscalWeek] = SELECTEDVALUE ( FiscalCalendar[FiscalWeek] )
                && FiscalCalendar[Date]
                    <= MAX ( FiscalCalendar[Date] ) - 364
        )
    )
RETURN
    DIVIDE ( thisYearValue - lastYearValue, lastYearValue )

 

041905.jpg


Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @slavisha84 

You could create below measures and put them in a table.

 

Revenue This Year = SUM(RevenueByDate[Revenue])


Revenue Last Year = CALCULATE(SUM(RevenueByDate[Revenue]),FILTER(ALL(FiscalCalendar[FiscalYear]),FiscalCalendar[FiscalYear]=SELECTEDVALUE(FiscalCalendar[FiscalYear])-1))


GrowthPerDay = DIVIDE(RevenueByDate[Revenue This Year]-[Revenue Last Year],[Revenue Last Year])


WeekToDateGrowth =
VAR thisYearValue =
    CALCULATE (
        SUM ( RevenueByDate[Revenue] ),
        FILTER (
            ALL ( FiscalCalendar ),
            FiscalCalendar[FiscalYear] = SELECTEDVALUE ( FiscalCalendar[FiscalYear] )
                && FiscalCalendar[FiscalWeek] = SELECTEDVALUE ( FiscalCalendar[FiscalWeek] )
                && FiscalCalendar[Date] <= MAX ( FiscalCalendar[Date] )
        )
    )
VAR lastYearValue =
    CALCULATE (
        SUM ( RevenueByDate[Revenue] ),
        FILTER (
            ALL ( FiscalCalendar ),
            FiscalCalendar[FiscalYear]
                = SELECTEDVALUE ( FiscalCalendar[FiscalYear] ) - 1
                && FiscalCalendar[FiscalWeek] = SELECTEDVALUE ( FiscalCalendar[FiscalWeek] )
                && FiscalCalendar[Date]
                    <= MAX ( FiscalCalendar[Date] ) - 364
        )
    )
RETURN
    DIVIDE ( thisYearValue - lastYearValue, lastYearValue )

 

041905.jpg


Kindly let me know if this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

amitchandak
Super User
Super User

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.