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.
Hi all,
I am now on the Power BI front and I am looking for some tips on how to do the following:
My data set:
Car | N-Cars | Miles-days |
BMW | 1 | 33 |
BMW | 2 | 44 |
FORD | 1 | 10 |
FORD | 2 | 40 |
FORD | 3 | 20 |
FORD | 4 | 33 |
I want to calculate the following:
Car | N-Cars | Miles-days | average miles-day / N-Cars |
BMW | 1 | 33 | 33 |
BMW | 2 | 44 | 38.5 |
FORD | 1 | 10 | 10 |
FORD | 2 | 40 | 25 |
FORD | 3 | 20 | 23.33333333 |
FORD | 4 | 33 | 25.75 |
Then plot this in a line diagram with Miles- days on Y-Axis and averaged value on X-axis.
For BMW it would be (1,33) next point (2,38.5).
Is there anybody here that could help with this?
Solved! Go to Solution.
hi @joggis ,
you can create a calculated column like this:
average miles-day / N-Cars =
VAR _currentNCar =
CALCULATE ( SELECTEDVALUE ( cars[N-Cars] ) )
VAR _currentCar =
CALCULATE ( SELECTEDVALUE ( cars[Car] ) )
RETURN
DIVIDE (
CALCULATE (
SUM ( cars[Miles-days] );
FILTER ( ALL ( cars ); cars[Car] = _currentCar && cars[N-Cars] <= _currentNCar )
);
_currentNCar
)
here is example I made using the data you have provided: pbix
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Hi @joggis
Try using the quick measure.
hi @joggis ,
you can create a calculated column like this:
average miles-day / N-Cars =
VAR _currentNCar =
CALCULATE ( SELECTEDVALUE ( cars[N-Cars] ) )
VAR _currentCar =
CALCULATE ( SELECTEDVALUE ( cars[Car] ) )
RETURN
DIVIDE (
CALCULATE (
SUM ( cars[Miles-days] );
FILTER ( ALL ( cars ); cars[Car] = _currentCar && cars[N-Cars] <= _currentNCar )
);
_currentNCar
)
here is example I made using the data you have provided: pbix
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |