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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
MLDerrick
Regular Visitor

How to show percentage increase or decrease of a cost value based on the first or last dated entry

I have a list of the records that I want to show from a SQL database and a line graph that shows those items which I can click on each of the lines and it works fine. But what I want to do next is have another visual that shows the % increase or decrease of the buying price based on the first entry of an item and the last entry. 

 

The dataset is something like this:

 

Order NoSupplierItemOrder dateQuantitybuying price
00012347813011122/07/2121.00
00012547813011122/08/2151.50
00012647813011122/09/2142.00
00012747813011122/10/2121.75
00012547713011222/09/21102.00
00013847713011222/10/2162.05
00015047713011222/11/2161.15

 

So with item 130111 the buying price of increased based on the first and last price. The buying prince of 130112 did the opposite. But I dont know how PowerBi visualises percentages. 

 

Cheers...

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I guess that could work as well. If you only got the decimal place wrong, just multiply the measure result by 100 😁

 

Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

View solution in original post

4 REPLIES 4
MLDerrick
Regular Visitor

Hi there, thanks for the reply. 

 

I can see how the measure works, but for some reason its not giving me the correct percentage value based on some real world data. 

Examples of my data that I need it to calculate. 

 

Item CodeDate orderedUnit price
26010414/04/2119.50
26010410/05/2119.50
26010415/06/2124.00
26010420/07/2124.00
26010415/08/2128.80
26010404/10/2128.80
26010418/11/2128.80
26010418/11/2128.80
26010418/11/2149.00
26010425/11/2149.00
26010421/12/2149.00
26010428/04/2249.00
26010412/07/2249.00

 

If I create a new visual for that measure it only gives me a 61.46% increase when its supposed to be more like 151%

 

Not sure where its getting that figure from. 

 

Also if I set it up at the 3 seperate measures, the "price per earlyest date" value always comes out at zero, instead of being the correct value for the item. I'm wondering if its picking up the lowest value in the whole table, which as it contains all of the prices for all of the items ever, it would have some items with zero values.

 

Anonymous
Not applicable

Hi

 

You can create the following metrics:

 

 

First one will create the earlyest date by id

min_date_id =
CALCULATE(
    MIN('Table'[date]),
    ALLEXCEPT('Table','Table'[Item])
)

 

Then create another to find the value for the minimum date:

 

price per earlyest date =
CALCULATE(
    MIN('Table'[price]),
    FILTER(
        all('Table'),
        'Table'[date] = min_date_id
    )
)

 

At least create another fot the division

 

Price % =
DIVIDE(
    sum('Table'[price]),
    [price per earlyest date]
)

 

or if you want, just put it all in the same metric:

 

Price % = 

VAR min_date_id =
CALCULATE(
    MIN('Table'[date]),
    ALLEXCEPT('Table','Table'[Item])
)

var min_price_date =
CALCULATE(
    MIN('Table'[price]),
    FILTER(
        all('Table'),
        'Table'[date] = min_date_id
    )
)

RETURN
DIVIDE(
    sum('Table'[price]),
    min_price_date
)

 

It seems complex, but it is quite simple. Either way, althought this works, if you find a more efficient solution, please share.

 

Hope it helps

 

Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Also, I found a different measure like this:

 

% Change =
DIVIDE(
CALCULATE(
SUM('TABLE'[PRICE]),
FILTER('TABLE','TABLE'[Date]=MAX('TABLE'[Date]))),
CALCULATE(
SUM('TABLE'[UnitPrice]),
FILTER('TABLE','TABLE'[Date]=MIN('TABLE'[Date]))),0) - 1
 
Which gives me a value of 1.51% when its supposed to be 151% 
 
So it is giving me the right answer, but with the decimal in the wrong place (this is right for all of the other items, 0.47% installed of 47% etc) 
Anonymous
Not applicable

I guess that could work as well. If you only got the decimal place wrong, just multiply the measure result by 100 😁

 

Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.