Forum Discussion
Ranks with filter function date
- 5 years ago
The problem was that your Val_Turb_Freq_1h measure was not returning values for the day level rows. Here is a new measure that seems to work. It's a little off as your hardcoded values use a value of 81 as the threshold but the overall result for Val_Turb_Freq_1h is 80. The result from this measure matches those when 80 is used.
NewMeasure =
VAR ValTurbFreq1h =
CALCULATE (
[Val_Turb_Freq_1h],
ALLSELECTED ()
)
VAR vStop =
COUNTROWS (
FILTER (
VALUES ( fact_points_mesures_faucon[dt (10 min)] ),
[Turbidité] >= ValTurbFreq1h
)
) / 6
RETURN
vStopAlso, the logic to get your threshold values seems to be the 144th value of Turbidity (regardless if the scope is day, month, year or all time). Is that your intended logic?
Pat
Can you give an example of another calculation that is impacted by the ALLSELECTED on that column?
Pat
mahoneypat I will try to explain my problem. First of all, I am French, which explains the writing of certain measures. I analyze the production of a hydroelectric power plant according to a turbidity threshold. Turbidity is the power of water. The higher its value is, the greater the risk of deteriorating our equipment. The definition of this threshold is important because it is the one that will determine whether or not we shut down the hydroelectric plant. My first objective was to find the turbidity value for a day of shutdown of the power station according to a period of time that I will have chosen thanks to the segment. To create this measurement I first used the "index" column of my Dataset and created the following measurement:
I used value 144 because my time base is in DT10MIN and therefore 24*6 is equal to 24h. The result obtained corresponds to my expectations. I then created a measure to calculate the downtime in h by first creating an "IF" function:
Arrêts turbidité_1j =
IF([Turbidité]>=[Val_Turb_Freq_1h],1,0)
Then a measurement that summarizes the downtime :
Arrêts turbidité_temps_1j (en h) =
SUMX(SUMMARIZE(VALUES(fact_points_mesures_faucon[dt (10 min)]),fact_points_mesures_faucon[dt (10 min)],"STOP",[Arrêts turbidité_1j]/6),[STOP])
problem, I get the result in the green table on the left.
However, when in the measurement "Arrêts turbidité_1j " I manually enter the turbidity threshold like this:
Arrêts turbidité_1j =
IF([Turbidité]>=80,1,0)
I get the result from the green table on the right and it's the correct one.
I would therefore like this result without having to manually enter the turbidity threshold since I have it automatically with the "Val_Turb_Freq_1h" measurement.
I hope it was understandable, thank you in advance,
Joël
- mahoneypat5 years agoMicrosoft Employee
I spent some time looking at it and am still a little confused at the calculation you are trying to do (the green tables aren't in the model). I'm sure there is a simpler way to calculate this. Can you explain in one sentence what you are looking for? In any case, one suggestion is to calculate [Val_Turb_Freq_1h] as a variable up front.
Arrêts turbidité_temps_1j (en h) =
var ValTurbFreq1h = [Val_Turb_Freq_1h]
Return
SUMX(SUMMARIZE(VALUES(fact_points_mesures_faucon[dt (10 min)]),fact_points_mesures_faucon[dt (10 min)],"STOP",IF([Turbidité]>=ValTurbFreq1h,1,0)/6),[STOP])Pat
- Anonymous5 years agoNot applicable
Thank you again for your time mahoneypat . I have updated the PBIX link by adding the two green boards. I tested the formula but unfortunately it doesn't work ...
https://1drv.ms/u/s!Ao1OrcTeY008gYU2OOM2oBSrDBzgpQ?e=NBEX1B
Joël
- mahoneypat5 years agoMicrosoft Employee
Thank you. I'll take a look this evening after work (but others should feel free to chime in to help too). Can you also provide a one-sentence summary of the desired calculation? I may start from scratch (the current approach isn't performant even when it gets fixed).
Pat