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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
galavichid
Regular Visitor

Calculate percentage from time value calculated by another 'measure'

Hi All,

 

I am trying to create calculation of a value I get with the measure:

 

 

 

 

 

GAL = 
VAR Total_Hours =
    SUMX(
        'GAL',
        HOUR('GAL'[TotalTime]) + DIVIDE(MINUTE('GAL'[TotalTime]),60) + DIVIDE(SECOND('GAL'[TotalTime]),3600)
    )
VAR DaysTotal = DIVIDE(Total_Hours,24)
VAR HoursTotal = (DaysTotal)*24
VAR HoursInt = TRUNC(HoursTotal)
VAR MinutesTotal = (HoursTotal - HoursInt)*60
VAR MinutesInt = TRUNC(MinutesTotal)
VAR SecondsTotal = ROUND((MinutesTotal - MinutesInt)*60,0)
RETURN
    FORMAT(HoursInt,"00")&"h, "&FORMAT(MinutesInt,"00")&"m, "&FORMAT(SecondsTotal,"00")&"s "

 

 

With this measure will present me the amount of hours calculate from the column 'TotalTime'. It will be presented like this: 

87h, 22m, 22s

 

I would like to take the 'hours' and calculate how much percentage it will be out of 192 for example.

 

I have tried to use this:

Percentage = DIVIDE(ExistingMeasureValue, TotalMeasureValue, 0) * 100

But i get an error it can't use the hours value to calculate.

 

Any other suggestion ?

1 ACCEPTED SOLUTION
bsheffer
Continued Contributor
Continued Contributor

your GAL measure has a variable for hours: 

Total_Hours

if you created a new measure that filled that variable the same way and another variable that had your total_value (192) then you could just return

divide(total_hours, total_value) and format the measure as a percentage

View solution in original post

6 REPLIES 6
bsheffer
Continued Contributor
Continued Contributor

please show the actual measure or variable names you are using to calculate

 

Percentage = DIVIDE(ExistingMeasureValue, TotalMeasureValue, 0) * 100

 

 

I use this to get the total amount of hours from Excel file:

GAL = 
VAR Total_Hours =
    SUMX(
        'GAL',
        HOUR('GAL'[TotalTime]) + DIVIDE(MINUTE('GAL'[TotalTime]),60) + DIVIDE(SECOND('GAL'[TotalTime]),3600)
    )
VAR DaysTotal = DIVIDE(Total_Hours,24)
VAR HoursTotal = (DaysTotal)*24
VAR HoursInt = TRUNC(HoursTotal)
VAR MinutesTotal = (HoursTotal - HoursInt)*60
VAR MinutesInt = TRUNC(MinutesTotal)
VAR SecondsTotal = ROUND((MinutesTotal - MinutesInt)*60,0)
RETURN
    FORMAT(HoursInt,"00")&"h, "&FORMAT(MinutesInt,"00")&"m, "&FORMAT(SecondsTotal,"00")&"s "

 

bsheffer
Continued Contributor
Continued Contributor

no, I wanted to see the values or measures you wanted to plug into 

Percentage = DIVIDE(ExistingMeasureValue, TotalMeasureValue, 0) * 100  based on your GAL measure

 

galavichid_0-1677707222509.png

galavichid_1-1677707248868.png

The vaules from the TotalTime colmun, are calculated by the measure above.

Its the only measure i have, I thought to use this measure, and do the calculation from the value i get from it. 

Could be i am not in the right direction at all, i am very new to Power BI.

 

Thanks

 

bsheffer
Continued Contributor
Continued Contributor

your GAL measure has a variable for hours: 

Total_Hours

if you created a new measure that filled that variable the same way and another variable that had your total_value (192) then you could just return

divide(total_hours, total_value) and format the measure as a percentage

Thanks so much

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.