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.
Hello to all, I have 2 questions. As you can see below, I have a bar chart. I want to calculate the average of the column and show it in the little box. On the chart, I added the Average Line automatically, showing 165.42. It is the Average of the columns in the chart. I want to calculate the same thing with a formula. I used this formula for a little box.
@SpartaBI @amitchandak @tamerj1
Hi @demder ,
According to your description, I create a sample.
Here's my solution, create a measure.
Total_Cost average per ReservationID =
DIVIDE (
SUMX ( VALUES ( 'Booking' ), 'Booking'[Total_Cost] ),
DISTINCTCOUNT ( Booking[Month] )
)
For the quarterly average value, create another measure.
Ave Quarterly =
AVERAGEX (
FILTER (
ALLSELECTED ( 'Booking' ),
YEAR ( 'Booking'[Month] ) = YEAR ( MAX ( 'Booking'[Month] ) )
&& QUARTER ( 'Booking'[Month] ) = QUARTER ( MAX ( 'Booking'[Month] ) )
),
'Booking'[Total_Cost]
)
* DISTINCTCOUNT ( 'Booking'[ReservationID] )
Get the result.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello @v-yanjiang-msft ,
It helps me a lot but some parts are still missing. I couldn't get an accurate result to me. I'm adding to my .pbix file here. On page 3 I got the correct result thanks to your solutions. On page 4, you can see another graph. I want to calculate the average total cost per month (Total Cost/Distinct court). Also, I want to calculate the Average total cost per quarterly. (Total Cost/Distinct court). I couldn't calculate correctly the second part I think, I'm doing something wrong.
https://drive.google.com/file/d/1cyMla1HSTpYiRmsYtcOfmJ4Q5jrZFVQJ/view?usp=sharing
I couldn't add the file that's why Im adding the drive link.
Hi @demder ,
Sorry I can't reach your file in the work network. Not sure what's the difference between page3 and page4. Maybe you can clarify it by snapshots if it's not so complex.
Best Regards,
Community Support Team _ kalyj
Hello @v-yanjiang-msft ,
Sorry for that, I uploaded the file to my personal account g-drive. I think you can open it now.
https://drive.google.com/drive/folders/17NcJQ7dIw_JHdeZad4o_E8zdj1ZIKOyz?usp=sharing
Hi @demder ,
Sorry I maybe can't figure out the logical in your sample, the relationship of court ID and reservation ID, the problem seems not the same with the original post which needs an average value for all the bars in box. Then if the page 3 works fine why still add a page 4 which seems calculate same things.
Best Regards,
Community Support Team _ kalyj
Hi @demder ,
Sorry I still can't open it, maybe it's because of my work network setting.
Best Regards,
Community Support Team _ kalyj
@demder
for the title box you can try this code, where the year month should be a column in your date table thank combines the year and the month in any shape. To see the quarter average you can drill up the x-axis.
Total_Cost average =
AVERAGEX (
VALUES ( 'Date'[YearMonth] ),
CALCULATE ( SUM ( 'Booking'[Total_Cost] ) )
)
I created new column with
Please try it with KEEPFILTERS
Total_Cost average =
AVERAGEX (
KEEPFILTERS ( VALUES ( 'Date'[YearMonth] ) ),
CALCULATE ( SUM ( 'Booking'[Total_Cost] ) )
)
Hello @tamerj1 ,
Yes, I have. Also I created, a common one-date table for all values. with this code;
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 |
---|---|
111 | |
97 | |
80 | |
69 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |