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

Calculate % Change By Month for Multiple Categories

Hi,

 

I have an opportunity tracker where I'm trying to calculate the percentage change in the number of opportunities from month to month. My table looks like this where I have the month and I've calculated the total number of opportunities per category by month and I want to generate the % Change column. Thanks in advance for any help.

 

YearMonthQuarterCategoriesTotal HoursNumber of Opportunities% Change
20224Q2A1930
20224Q2B2040
20224Q2C1550
20224Q2D1060
20224Q2E580
20225Q2A72-33%
20225Q2B103-25%
20225Q2C204-20%

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @QuinnG,

I'd like to suggest you add a custom column to merge year month field values, then you can use it as a condition to calculate the '% changes' based on category:

calculate column:

YearMonth =
Table[Year] * 100 + Table[Month]

Measure:

formula =
VAR currYearMonth =
    MAX ( Table[YearMonth] )
VAR prevYearMonth =
    CALCULATE (
        MAX ( Table[YearMonth] ),
        FILTER ( ALLSELECTED ( Table ), [YearMonth] < currYearMonth ),
        VALUES ( Table[Category] )
    )
VAR currOpp =
    MAX ( Table[Number of Opportunities] )
VAR prevOpp =
    CALCULATE (
        MAX ( Table[Number of Opportunities] ),
        FILTER ( ALLSELECTED ( Table ), [YearMonth] = prevYearMonth ),
        VALUES ( Table[Category] )
    )
RETURN
    DIVIDE ( currOpp - prevOpp, prevOpp )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @QuinnG,

I'd like to suggest you add a custom column to merge year month field values, then you can use it as a condition to calculate the '% changes' based on category:

calculate column:

YearMonth =
Table[Year] * 100 + Table[Month]

Measure:

formula =
VAR currYearMonth =
    MAX ( Table[YearMonth] )
VAR prevYearMonth =
    CALCULATE (
        MAX ( Table[YearMonth] ),
        FILTER ( ALLSELECTED ( Table ), [YearMonth] < currYearMonth ),
        VALUES ( Table[Category] )
    )
VAR currOpp =
    MAX ( Table[Number of Opportunities] )
VAR prevOpp =
    CALCULATE (
        MAX ( Table[Number of Opportunities] ),
        FILTER ( ALLSELECTED ( Table ), [YearMonth] = prevYearMonth ),
        VALUES ( Table[Category] )
    )
RETURN
    DIVIDE ( currOpp - prevOpp, prevOpp )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@QuinnG , Create a date from month and year, if you do not have a date

Date = Date([Year], [Month],1)

 

Try measures like

Join this date with date of a date table, and use column from that date table in visual

 

MTD = CALCULATE(AverageX(values('Date'[Date]), calculate(SUM(Table[Qunatity Produced])) ),DATESMTD('Date'[Date]))

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
next month Sales = CALCULATE(SUM(Sales[Sales Amount]),nextmonth('Date'[Date]))
this month = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH('Date'[Date])))

 

 

with help from column month Rank

 

 

Mesures

Month Rank = RANKX(all('Date'),'Date'[Year Month],,ASC,Dense)

Measure
This Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...

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.