Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe 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.
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!
Solved! Go to Solution.
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.
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,
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.
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.
You are welcome.
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.
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.
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...
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
80 | |
53 | |
39 | |
39 |
User | Count |
---|---|
104 | |
85 | |
47 | |
44 | |
43 |