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
wolfboyjan
New Member

Creating an Index in Power BI - help with calculating based on current row value

I'm trying to create an Index of times, to show whether individual runners are getting faster or slower over time, with a runner's first time as 100.0 and any decrease in future times being expressed as a reduction, e.g. a 10% faster time would be expressed as 90.0, and so on.

 

I understand how to achieve this in a couple of ways using Excel, with some combination of MINIFS and pivot tables, but I'd like to do this in Power BI.

 

I thought it would be quite straightforward to create a column that shows a runners first time and then to use this to further calculate the Index value (time / first time), but I don't seem to be able to achieve this.

 

Here's an extract of the "data" table where the information is held:

 

event_nameevent_dateevent_numberrunner_positionrunner_namerunner_genderrunner_time
Lyme Park parkrun25/02/20233901Runner aMale00:19:20
Lyme Park parkrun25/02/20233902Runner bMale00:20:32
Lyme Park parkrun25/02/20233903Runner cMale00:20:40
Lyme Park parkrun25/02/20233904Runner dMale00:21:45
Lyme Park parkrun04/03/20233911Runner eMale00:18:46

 

And here's the custom column I have tried to create, which currently only works when I manually enter a runner's name ("John Smith" in the example below):

 

First_time = LOOKUPVALUE(data[runner_time],data[runner_name],"John Smith",data[event_date],data[First_week])

 

In Excel I would simply refer to the specific cell within the current row of the "runner_name" column, but I realise this isn't the right approach in Power BI. I have searched online and tried to use the EARLIER function, but receive error messages which I have been unable to resolve.

 

Any help with this and/or how to produce the Index I described would be really appreciated!

7 REPLIES 7
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

No problem, here's a one drive link to some sample data: example_data.csv 

 

I'd like to create:

 

  1. A column that shows the earliest date a runner appears in the data (dd/mm/yy)
  2. A column that shows the time that the runner achieved on that earliest date (h:mm:ss)
  3. An index column that shows the difference between their earliest time and their current time (decimal number)

Thanks

Hi,

These calculated column formulas should answer the first 2 questions

Earliest date of runner = CALCULATE(MIN(Data[event_date]),FILTER(Data,Data[runner_name]=EARLIER(Data[runner_name])))
Time at earliest date = LOOKUPVALUE(Data[runner_time],Data[event_date],Data[Earliest date of runner],Data[runner_name],Data[runner_name])

Hope this helps.

Untitled.png


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

Thank you for your help and time. I tried to implement this but received the error: "A table of multiple values was supplied where a single value was expected." when I try to create the Time at earliest date column". 

 

Unfortunately I can't see any more detail about which column is generating this error. 

You are welcome.  Share the download link of the PBI file.  Show the problem and expected result clearly.


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

lbendlin_0-1679347094098.png

have fun analyzing the data

Thanks very much for sharing that solution. Do you know if it's possible to adapt this approach to allow me to chart runner progress over time, rather than the first vs latest run?

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.