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.
Hi all,
First time using this forum so I hope I'm posting in the right place.
I am trying to work out how to dynamically change the amount of minutes in a day based on the date range chosen in a slicer. Basically I am looking for the unnaccounted for minutes on machines in our factory.
Currently I have set up a column that has all values as 1440 (max minutes in a day) and subtract all the accounted for minutes to work out what is missing - When I change this to run over say a weekend, It is still working out unnaccounted for minutes based on one day. Is there a function where Power BI can work out how many total minutes are available based on the date range in the slicer?
Below are my graphs for reference.
Over a one day period
Over a weekend
Many Thanks in advance,
Steve
Solved! Go to Solution.
@StephenK2022
Yes becuase DATEDIFF return 0 for the same date difference. Please try
Logged mins vs total mins (Total Accounted for Mins minus Average of TOTAL MINUTES) =
VAR FirstDateInFilter =
MINX (
ALLSELECTED ( '24hr production report'[Dates] ),
'24hr production report'[Dates]
)
VAR LastDateInFilter =
MAXX (
ALLSELECTED ( '24hr production report'[Dates] ),
'24hr production report'[Dates]
)
VAR TotalMinutes =
DATEDIFF ( FirstDateInFilter, LastDateInFilter + 1, MINUTE )
VAR AccountedMinutes =
SUM ( '24hr production report'[Total Accounted for Mins] )
RETURN
ABS ( TotalMinutes - AccountedMinutes )
Hi @tamerj1 ,
Thanks for your reply,
I am using a measure to work out the unaccounted for mins, the problem is that i am using a column with only 1440 in it. So when I change the date I need a function which will change the value to the maximum minutes over that time period - Basically all the bars in the chart should add up to the total minutes over that time period and all should be the exact same height.
Ok Please try
Logged mins vs total mins (Total Accounted for Mins minus Average of TOTAL MINUTES) =
VAR FirstDateInFilter =
MINX (
ALLSELECTED ( '24hr production report'[Dates] ),
'24hr production report'[Dates]
)
VAR LastDateInFilter =
MAXX (
ALLSELECTED ( '24hr production report'[Dates] ),
'24hr production report'[Dates]
)
VAR TotalMinutes =
DATEDIFF ( FirstDateInFilter, LastDateInFilter, MINUTE )
VAR AccountedMinutes =
SUM ( '24hr production report'[Total Accounted for Mins] )
RETURN
ABS ( TotalMinutes - AccountedMinutes )
Thanks very much, this worked for date ranges over 2 days, however now when we look over one day we are getting this:
Over a longer time period:
I'm guessing it is an issue due to "first date in filter" and "last date in filter" being the same value?
Thanks again
@StephenK2022
Yes becuase DATEDIFF return 0 for the same date difference. Please try
Logged mins vs total mins (Total Accounted for Mins minus Average of TOTAL MINUTES) =
VAR FirstDateInFilter =
MINX (
ALLSELECTED ( '24hr production report'[Dates] ),
'24hr production report'[Dates]
)
VAR LastDateInFilter =
MAXX (
ALLSELECTED ( '24hr production report'[Dates] ),
'24hr production report'[Dates]
)
VAR TotalMinutes =
DATEDIFF ( FirstDateInFilter, LastDateInFilter + 1, MINUTE )
VAR AccountedMinutes =
SUM ( '24hr production report'[Total Accounted for Mins] )
RETURN
ABS ( TotalMinutes - AccountedMinutes )
That seems to have done the trick - Thank you so much, this will be very helpful.
I wil run a few more tests just to make sure and then I can accept as solution for you.
Thanks again
Nice chart!
It seems you are utilizing calculated columns which cannot be dynamic. You need to use measures instead. Please provide more details and a sample data along with the expected results.
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 |
---|---|
95 | |
94 | |
80 | |
71 | |
64 |
User | Count |
---|---|
115 | |
106 | |
96 | |
81 | |
72 |