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

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.

Reply
Anonymous
Not applicable

Dynamically calculating column in a table based on slicer value

Hi all,

 

In one of my tables I have a list of IT systems, and a column that lists, for each system, the amount of hours said system has been down or non-functional. I'm tryinng to calculate the proportion of a selected period of time that a given system was down for.

 

For example, if system X was down for 12 hours on the 3rd of March:

- There are 744 hours in March, so if I selected March in a slicer I would like to display that it was down for 1.612%

- There are 2160 hours in the first quarter of the year, so if i selected Q1, I'd like to display that it was down for 0.56%

- There are 8760 hours in a year, so if i selected a whole year I'd like to display that it was down for 0.14%

 

I am using a date table that has a column for hours, which has a value of 24 in every row. (I didn't allow for daylight savings etc as that level of accuracy wasn't necessary). When I display the amount of hours I use SUM(Hours).

 

My current formula is %Downtime = Downtime / SUM('Date'[Hours]). At the moment, I have 3 years worth in my date table and no matter what date range I select in the report, every %Downtime value is shown as "Downtime / 26,280".

 

What do I have to do to get this value to change based on the date range I select?

 

Thanks 🙂

1 ACCEPTED SOLUTION

From the image looks like you have created an calculated column, and i would recomend to change that to a measure. 
Also, i have made a little test on my side and it should work like this:

 

% Downtime = [Downtime] / (SUM('Calendar'[Day]) * 24)
(considering the [Downtime] is a measure in hours)
 
and it works with day, months or even years...
SergioSilvaPT_1-1652697805887.png

 

Regards,

Sérgio Silva 

 
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

 

Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/

View solution in original post

6 REPLIES 6
SergioSilvaPT
Resolver V
Resolver V

Hi @Anonymous ,

 

Can you show us your model? Is the Calendar table connected to the table from were you get the downtime values?

Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/
Anonymous
Not applicable

MCK24_0-1652693133435.png 

Yes, the Date Table is directly related to the table that has the downtime values

 

From the image looks like you have created an calculated column, and i would recomend to change that to a measure. 
Also, i have made a little test on my side and it should work like this:

 

% Downtime = [Downtime] / (SUM('Calendar'[Day]) * 24)
(considering the [Downtime] is a measure in hours)
 
and it works with day, months or even years...
SergioSilvaPT_1-1652697805887.png

 

Regards,

Sérgio Silva 

 
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

 

Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/
Anonymous
Not applicable

How is that 'Day' column formatted in your model? 

Also could you show me how you made your 'Downtime' measure?

Also, I think the fact that it looked like a calculated column was an error on my part. See here:

MCK24_0-1652698677456.png

 

Anonymous
Not applicable

Never mind, I figured that part out. It works now, Thanks!

Glad i could help!

Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.