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

How to calculate price variation between periods

Hi Everyone,

 

I need to calculate the variation of prices overtime of a group of products but takinng into account only products that were sold in both periods being compared.

Below you have an illustrative example of the data I am using 

ProductQ1Q2Q3Q4
A101100
B1515120
C0111414
D001010
E001010
F00010

 

In this case, I want to calculate the average variation of prices from Q1 to Q2, therefore I need to consider only products A and B as the others were not sold in Q1. If I am comparing Q2 to Q3 it will be then products B and C.


I have unpivot the data as below but I am not finding a way to create a measure that make filter as needed.

ProductPeriodPrice
AQ110
BQ115
CQ10
.........

 

Any help will be verymuch appreciated.

 

 

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

If I understand your requirement that you want to calculate the variation of prices between this beriod and last period?

If so, you could create an index column before unpivoting the column in query editor and then create the calculated column like below.

Column 2 = 
VAR a =
    CALCULATE (
        MAX ( 'Table'[Price] ),
        FILTER (
            'Table',
            'Table'[Period] = EARLIER ( 'Table'[Period] )
                && 'Table'[Index]
                    = EARLIER ( 'Table'[Index] ) + 1
        )
    )
RETURN
    'Table'[Price] - a

Here is the output.

Capture.PNG

If you still need help, please share your desired output so that we could help further on it.

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-piga-msft ,

 

Thank you for the suggestion but it is not what I am looking for. I am interested to understand the variation of the group of products between quarters.

 

If we take Q2 vs Q1, we should sum the products that were sold in both periods, which are products A and B. The calculation would be then 26 over 25 that gives +4% variation. When I tried to create the calculation, I did not find a way to filter only product A and B and therefore the result is including product C in Q2 that result in total of 37.

 

I hope this clarifies my problem. 

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.