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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Different formulas depending on time granularity used to display my graph

Hi all,

 

I have the following table

 

DateTimeUsageInSecondsUser
24/1/202310 AM1800A
24/1/202310 AM900B
24/1/202311 AM450

A

24/1/202312 PM900A
24/1/202312 PM1800B
24/1/202312 PM450

C

24/1/20231 PM3600

D

 

And I want to compute the total hourly, daily, monthly, yearly percentage usage, which I would do with these fomulas:

 

HourlyUsagePercentage = UsageInSeconds/3600 * 100

DailyUsagePercentage = HourlyUsagePercentage / 24

MonthlyUsagePercentage = DailyUsagePercentage / 31 (would be better to adjust depending on the number of days in that month)

YearlyUsagePercentage = DailyUsagePercentage / 365 (account for leap year)

 

 

What I need, is a column that display one of the above values depending on the granularity that the graph is currently using to display the data. But how do I get the information regarding the granularity in use?

 

Also, I'm new to Power BI. That is how I would tackle this prolem, but any different solution/suggestion is welcome.

 

Thank you!

2 REPLIES 2
SamInogic
Super User
Super User

Hi @Anonymous ,

You can use below 5 DAX expressions to create these 5 usage columns:


HourlyUsagePercentage = Usage[UsageInSeconds]/3600

 

DailyUsagePercentage = (Usage[HourlyUsagePercentage] / 24 )

 

MonthlyUsagePercentage =

 VAR t = Usage[Date].[Date]

var NoOfDaysInMonth =  

    COUNTROWS(

        CALENDAR(

            FORMAT(t,"YYYY-MM-01") ,

            EDATE(FORMAT(t,"YYYY-MM-01"),1)-1

           )

    )

    return Usage[DailyUsagePercentage] /NoOfDaysInMonth

 

YearlyUsagePercentage =

var NoOfDaysInYear =

COUNTROWS (

    CALENDAR (

        DATE ( Usage[Date].[Year], 1, 1 ),

        DATE (  Usage[Date].[Year], 12, 31 )

    )

)

return Usage[DailyUsagePercentage] / NoOfDaysInYear

 

Also, make sure the format for the columns should be Percentage.


Please refer to the below screenshot for the same,

SamInogic_0-1682338710991.png

 

If this answer helps, please mark it as an Accepted Solution so it would help others to find the solution.


Thanks!

Inogic Professional Service Division

An expert technical extension for your techno-functional business needs

Power Platform/Dynamics 365 CRM

Drop an email at crm@inogic.com

Service:  http://www.inogic.com/services/ 

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/
Anonymous
Not applicable

Hi @SamInogic and thank you for your reply.

Your solution let me create 5 columns, but how do I visualize all 5 in the same graph, while allowing the drilling feature to select which one to show?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors