Average Duration DAX Power BI - powerbi

I'm trying to get the mean of a variable typed 'duration' in Power BI, creating a measure like in this formula:
Medida = AVERAGE(Consolidado[TMA])
When I try this it returns a decimal number like '0.003..', but I can't modify this measure to duration/time.
Can someone give me a hint?

The DAX is basically summarizing the result. To overcome this issue add the FORMAT function at the beginning and format it accordingly as you need.
Measure = FORMAT(AVERAGEA('Table'[Date]), "HH:MM:SS")
This should give you the output in the Time Format.

Related

Add Manual Formulas in Power BI Table Visualization

Is it possible to perform calculations based off of the Table Visualization's values? I understand Power BI has the option manually add columns in the data set but that will not work in this example because of how the data is aggregated.
Basically, I would want the option to create a formula next to revenue where I would divide revenue by cost.
enter image description here
As has been mentioned, a measure would be the solution. Something like the following
Measure = DIVIDE(CALCULATE(MAX(Table[Revenue])), CALCULATE(MAX(Table[Cost])), 0)

Power BI YTD Calculations

I am trying to do some time based calculations on my budgeting data but struggling to understand where I'm going wrong or if my data structure would even support what I'm trying to do.
As per the image above, this is my raw data. ie. A monthly budgeted and actual total for each cost centre that is being imported from an excel spreadsheet.
I am trying to calculate a YTD budget and YTD Actual figure per cost centre based on the monthly totals. Ideally I would like all of this data displayed in a table that I can then use slicers to segment/pivot.
When using the CALCULATE() function in a measure, I am unable to select my cell value for each date and cost centre.
eg.
YTD Actual = CALCULATE( [Actual MTH] , DATESYTD('Dates'[Date], "30/6"))
returns the error
The value for 'Actual MTH' cannot be determined. Either 'Actual MTH'
doesn't exist, or there is no current row for a column named 'Actual
MTH'.
Any assistance with getting a greater understanding of the issue here would be appreciated.
Thanks
Try something like this for your measures:
YTD Actual = TOTALYTD(sum([Actual MTH]),'Dates'[date],ALL('Dates'[date]),"30/6")

To show number in million (M) by using custom format

I have to display Value 71,672,885 as 71.6M and I'm using below DAX
IF(Metric[EU]>=1000000,FORMAT(Metric[EU],"#,##0.0,,M")
But its showing value as 71,672,885.0 M. Let me know what I'm missing in above DAX function.
Note: Above function working perfectly in Excel but not in Power BI.
The commas should be before the decimal place.
FORMAT(Metric[EU], "#,##,,.0M")
Here's the function reference:
https://learn.microsoft.com/en-us/dax/custom-numeric-formats-for-the-format-function

Filtered LOD calculations in DAX expression Power BI

I have created LOD expressions in Tableau before which dynamically calculate when filters are applied. I am trying to achieve similar functionality in Power BI. I am very new to Power BI so I probably didn't ask google the right question. I simply want a column that shows the average sales over my "Filtered" data set. The closest I cam was using the Calculate(average(table[column]),All(table)) but that does not dynamically change when I apply the date slider. If I filter for 1/1 - 1/5 I want that average. Change the date range, the average should change.
Thank you.
You are probably looking for the ALLEXCEPT() function. In this case you would do something like
CALCULATE(AVERAGE(table[column]), ALLEXCEPT(table, table[date]))
that is basically saying that you want to remove all filters on the table except the filters on the date column.
CALCULATE(
AVERAGE(Table[Column]),
ALLSELECTED()
)

POWER BI datesdifference excluding weekends

This is formula that i use
CALCULATE(SUM(Dates[IsWorkDay]),DATESBETWEEN(Dates[Date],
'table1'[date1],'table1'[Date2])))
This is the formula I use... between dates that look like below image.. I want to exclude weekends..... but the result that I get is not correct .... when the actual difference is only one day ... I get it as 4 days ... it differs a lot.. can some one please help
enter image description here
The Data type of all the dates in the formula needs to be in the same format.
For Example: keep it as just date(mm/dd/yy).
Your calculated column is right and it should work once you fix the data types.