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
Anonymous
Not applicable

YoY,WoW,QoQ,MoM

hi all,

 I need your help in building a visual in such a way that I have YoY,MoM,QoQ and WoW for all the calculated measures.

 

Please find below for the format of the data and desired output.

Data Format:

DateProductSalesUnits

01/01/2019

A5151210
01/01/2020A5481152
01/01/2021A1584515

 

Output:

 20202021YoY
Sales5481115845-38966
Units5215-37

 

The same for MoM and QoQ and WoW

 

Thanks in advance

2 ACCEPTED SOLUTIONS
Geradav
Responsive Resident
Responsive Resident

@Anonymous 
Here is what I came up with for Quarter over Quarter

QoQ =
VAR SelectedQuarter =
    YEAR ( MIN ( TableDoD[Date] ) ) & QUARTER ( MIN ( TableDoD[Date] ) )
VAR PrevQuarter =
    YEAR ( MIN ( TableDoD[Date] ) - 1 )
        & QUARTER ( MIN ( TableDoD[Date] ) - 1 )
VAR vQTotal =
    CALCULATE (
        SUM ( TableDoD[Units] ),
        FILTER (
            ALL ( TableDoD[Date] ),
            YEAR ( TableDoD[Date] ) & QUARTER ( TableDoD[Date] ) = SelectedQuarter
        )
    )
VAR vPQTotal =
    CALCULATE (
        SUM ( TableDoD[Units] ),
        FILTER (
            ALL ( TableDoD ),
            YEAR ( TableDoD[Date] ) & QUARTER ( TableDoD[Date] ) = PrevQuarter
        )
    )
VAR Dif = vQTotal - vPQTotal
VAR Result =
    SWITCH ( TRUE (), Dif = 0, Dif, Dif > 0, "+" & Dif, Dif < 0, Dif )
RETURN
    Result

View solution in original post

V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, you only need to create year, month, quarter and week columns respectively, and then apply this measure in different scenarios.

Revenue in same period last year = CALCULATE([Revenue],SAMEPERIODLASTYEAR('Calendar'[Date]))

Variance = IF(NOT(ISBLANK([Revenue in same period last year])),[Revenue]-[Revenue in same period last year])

 

Sample .pbix

 

Best Regards,
Liang
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

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, you only need to create year, month, quarter and week columns respectively, and then apply this measure in different scenarios.

Revenue in same period last year = CALCULATE([Revenue],SAMEPERIODLASTYEAR('Calendar'[Date]))

Variance = IF(NOT(ISBLANK([Revenue in same period last year])),[Revenue]-[Revenue in same period last year])

 

Sample .pbix

 

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

Geradav
Responsive Resident
Responsive Resident

@Anonymous 

Imagining you have only one table and no calendar date, you could try the following. To obtain the selected value I used the date column as a filter visual. The same function can be adapted for Quarter, Month and week.

YoY = 
VAR SelectedDate =
    YEAR ( MIN ( TableDoD[Date] ) )
VAR vYTD =
    CALCULATE (
        SUM ( TableDoD[Units] ),
        FILTER ( ALL ( TableDoD[Date] ), YEAR ( TableDoD[Date] ) = SelectedDate )
    )
VAR vLYTD =
    CALCULATE (
        SUM ( TableDoD[Units] ),
        FILTER ( ALL ( TableDoD ), YEAR ( TableDoD[Date] ) = SelectedDate - 1 )
    )
VAR Dif = vYTD - vLYTD
RETURN
    SWITCH ( TRUE (), Dif = 0, Dif, Dif > 0, "+" & Dif, Dif < 0, Dif )

Let us know if that works for you

 

David

Geradav
Responsive Resident
Responsive Resident

@Anonymous 
Here is what I came up with for Quarter over Quarter

QoQ =
VAR SelectedQuarter =
    YEAR ( MIN ( TableDoD[Date] ) ) & QUARTER ( MIN ( TableDoD[Date] ) )
VAR PrevQuarter =
    YEAR ( MIN ( TableDoD[Date] ) - 1 )
        & QUARTER ( MIN ( TableDoD[Date] ) - 1 )
VAR vQTotal =
    CALCULATE (
        SUM ( TableDoD[Units] ),
        FILTER (
            ALL ( TableDoD[Date] ),
            YEAR ( TableDoD[Date] ) & QUARTER ( TableDoD[Date] ) = SelectedQuarter
        )
    )
VAR vPQTotal =
    CALCULATE (
        SUM ( TableDoD[Units] ),
        FILTER (
            ALL ( TableDoD ),
            YEAR ( TableDoD[Date] ) & QUARTER ( TableDoD[Date] ) = PrevQuarter
        )
    )
VAR Dif = vQTotal - vPQTotal
VAR Result =
    SWITCH ( TRUE (), Dif = 0, Dif, Dif > 0, "+" & Dif, Dif < 0, Dif )
RETURN
    Result
amitchandak
Super User
Super User
Anonymous
Not applicable

hi @amitchandak ,

 

Where the Years and YoY calculation to be displayed?

@Anonymous , You will get measures like this year, last year, and YOY.

 

Now You have to use union and summarize to create a table of what you want. Measure to measure and dimension conversion

 

union(
summarize('Table',"Measure","sales","This period",[SALES YTD],"Last period",[SALES LYTD],"POP",[SALES YOY])
summarize('Table',"Measure","unit","This period",[unit YTD],"Last period",[unit LYTD],"POP",[unit YOY])
)

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.