Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
MikePowerBI
Helper II
Helper II

Create Column that Shows an Increase or Decrease in Volumes per Product by Reporting Period

Hi there,

 

I have a dataset similar to the test data I created in the screenshot below. I am looking to create a column (either in DAX or in the Power Query Editor) which has a similar result to the "Calculated Column".

 

The goal is to create a column that showcases if a product has had an increase or decrease in its volume when compared to the previous reporting period. For example, based on the test data in the screenshot: Product C had volumes of 50, 70, and 60 in the reporting periods of December 2023, January 2024, and February 2024 respectively. As a result, the reporting period of January 2024 would say "Increase" (increase from 50 to 70) and the reporting period of February 2024 would say "Decrease" (decrease from 70 to 60). 

 

Any help would be greatly appreciated! 

 

MikePowerBI_0-1708028549253.png

 

2 ACCEPTED SOLUTIONS
v-weiyan1-msft
Community Support
Community Support

Hi @MikePowerBI ,

 

Based on your description and sample data provided,
you might consider using the following code to create Calculated column.

Change in Volume = 
VAR CurrentProduct = 'Table'[Product]
VAR CurrentPeriod = 'Table'[Reporting Period Order]
VAR CurrentVolume = 'Table'[Volume]
VAR PreviousVolume = 
    CALCULATE (
        SUM ( 'Table'[Volume] ),
        FILTER (
            'Table',
            'Table'[Product] = CurrentProduct
                && 'Table'[Reporting Period Order] = CurrentPeriod - 1
        )
    )
RETURN
    IF (
        PreviousVolume = BLANK (),
        BLANK (),
        IF ( CurrentVolume > PreviousVolume, "Increase", "Decrease" )
    )

Result is as below.

vweiyan1msft_0-1708049581910.png


Best Regards,
Yulia Yan

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

Ashish_Mathur
Super User
Super User

Hi,

Write these calculated column formulas

Previous volume = if(ISBLANK(CALCULATE(MAX(Data[Reporting Period]),FILTER(Data,Data[Product]=EARLIER(Data[Product])&&Data[Reporting Period]<EARLIER(Data[Reporting Period])))),BLANK(),LOOKUPVALUE(Data[Volume],Data[Reporting Period],CALCULATE(MAX(Data[Reporting Period]),FILTER(Data,Data[Product]=EARLIER(Data[Product])&&Data[Reporting Period]<EARLIER(Data[Reporting Period]))),Data[Product],Data[Product]))
Column = if(ISBLANK(Data[Previous volume]),BLANK(),if(Data[Volume]>Data[Previous volume],"Increase","Decrease"))

Hope this helps.

Ashish_Mathur_0-1708053700005.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Write these calculated column formulas

Previous volume = if(ISBLANK(CALCULATE(MAX(Data[Reporting Period]),FILTER(Data,Data[Product]=EARLIER(Data[Product])&&Data[Reporting Period]<EARLIER(Data[Reporting Period])))),BLANK(),LOOKUPVALUE(Data[Volume],Data[Reporting Period],CALCULATE(MAX(Data[Reporting Period]),FILTER(Data,Data[Product]=EARLIER(Data[Product])&&Data[Reporting Period]<EARLIER(Data[Reporting Period]))),Data[Product],Data[Product]))
Column = if(ISBLANK(Data[Previous volume]),BLANK(),if(Data[Volume]>Data[Previous volume],"Increase","Decrease"))

Hope this helps.

Ashish_Mathur_0-1708053700005.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur 

 

This solution also worked for me. Thank you very much for your support!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-weiyan1-msft
Community Support
Community Support

Hi @MikePowerBI ,

 

Based on your description and sample data provided,
you might consider using the following code to create Calculated column.

Change in Volume = 
VAR CurrentProduct = 'Table'[Product]
VAR CurrentPeriod = 'Table'[Reporting Period Order]
VAR CurrentVolume = 'Table'[Volume]
VAR PreviousVolume = 
    CALCULATE (
        SUM ( 'Table'[Volume] ),
        FILTER (
            'Table',
            'Table'[Product] = CurrentProduct
                && 'Table'[Reporting Period Order] = CurrentPeriod - 1
        )
    )
RETURN
    IF (
        PreviousVolume = BLANK (),
        BLANK (),
        IF ( CurrentVolume > PreviousVolume, "Increase", "Decrease" )
    )

Result is as below.

vweiyan1msft_0-1708049581910.png


Best Regards,
Yulia Yan

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

Hi @v-weiyan1-msft 

 

Thank you for your quick response and your support!

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.