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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Lanceometer
Helper I
Helper I

Visual Calculation using FIRST()

Hi Folks,

 

I have data for some suppliers and prices for a material:

Supplier Date NetPrice
SUP1 28.02.2024 20,66
SUP1 29.02.2024 20,66
SUP2 01.03.2024 16,95
SUP2 02.03.2024 16,95
SUP2 03.03.2024 16,95
SUP2 04.03.2024 16,95
SUP2 05.03.2024 19
SUP2 06.03.2024 19

 

I want to show where the price was going up or down per supplier.

 

The user wants to see this in an indexed line chart

something like this:

Lanceometer_0-1735550941583.png

you can see that also the supplier changed

 

so it is basically calculated 

Calculation = [Average of NetPrice] / FIRST([Average of NetPrice])
 
But when I do this in a visual calculation it doesn't work. Apperantly FIRST() does not respect the legend (even with the parameters for sorting blank values last). So it takes the first date of all suppliers. but for my second supplier the first value is then blank. this is why i get infinity values
 
Lanceometer_1-1735551213758.png

 

Any ideas on that?

1 ACCEPTED SOLUTION
ValtteriN
Community Champion
Community Champion

Hi,

As seen in the visual calculation table supplier appears twice in your filter context. Because of this it is easier not to use visual calculations in this case, since calculating first date for a specific supplier will be challenging. With normal dax you can e.g. create something like this:

first net price division =
var _s = SELECTEDVALUE('Table (47)'[Supplier])
  VAR _firstDate = CALCULATE(MIN('Table (47)'[Date]),ALL('Table (47)'[Date]),'Table (47)'[Supplier]=_s)
  RETURN
  DIVIDE([Average of NetPrice],
CALCULATE(
[Average of NetPrice],ALL('Table (47)'[Date]),'Table (47)'[Date]=_firstDate))
ValtteriN_0-1735568286509.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/








Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ValtteriN
Community Champion
Community Champion

Hi,

As seen in the visual calculation table supplier appears twice in your filter context. Because of this it is easier not to use visual calculations in this case, since calculating first date for a specific supplier will be challenging. With normal dax you can e.g. create something like this:

first net price division =
var _s = SELECTEDVALUE('Table (47)'[Supplier])
  VAR _firstDate = CALCULATE(MIN('Table (47)'[Date]),ALL('Table (47)'[Date]),'Table (47)'[Supplier]=_s)
  RETURN
  DIVIDE([Average of NetPrice],
CALCULATE(
[Average of NetPrice],ALL('Table (47)'[Date]),'Table (47)'[Date]=_firstDate))
ValtteriN_0-1735568286509.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/








Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.