Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
So I have a price column by day. This column can contain duplicates. I'm trying to create a column that returns "Y" when the value in the Price column is the Minimum amount. However, I only want to return one "Y" even though there can be two or more minimum prices. Is there a way to handle this? This is what I have:
Min Indicator =
IF (
CALCULATE (
MIN ( 'Historical'[Price] ),
FILTER (
'Historical',
'Historical'[Rank Key] = EARLIER ( 'Historical'[Rank Key] )
)
) = [Price],
"Y",
"N"
)
But if the minimum price shows up twice, it returns two "Y" values which I don't want.
Solved! Go to Solution.
Hi @Anonymous ,
Please try the following formula to create a column after adding a Index column:
Min Indicator =
VAR _min =
CALCULATE (
MIN ( 'Historical'[Price] ),
ALLEXCEPT ( Historical, Historical[Rank Key] )
)
VAR _first =
MINX (
FILTER (
'Historical',
'Historical'[Rank Key] = EARLIER ( 'Historical'[Rank Key] )
&& 'Historical'[Price] = _min
),
[Index]
)
//Or use FIRSTNONBLANK()
// var _f =
// CALCULATE (
// FIRSTNONBLANK ( 'Historical'[Index], TRUE () ),
// FILTER (
// 'Historical',
// 'Historical'[Rank Key] = EARLIER ( Historical[Rank Key] )
// && 'Historical'[Price] = _min
// )
// )
RETURN
IF ( _first = [Index], "Y", "N" )
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Please try the following formula to create a column after adding a Index column:
Min Indicator =
VAR _min =
CALCULATE (
MIN ( 'Historical'[Price] ),
ALLEXCEPT ( Historical, Historical[Rank Key] )
)
VAR _first =
MINX (
FILTER (
'Historical',
'Historical'[Rank Key] = EARLIER ( 'Historical'[Rank Key] )
&& 'Historical'[Price] = _min
),
[Index]
)
//Or use FIRSTNONBLANK()
// var _f =
// CALCULATE (
// FIRSTNONBLANK ( 'Historical'[Index], TRUE () ),
// FILTER (
// 'Historical',
// 'Historical'[Rank Key] = EARLIER ( Historical[Rank Key] )
// && 'Historical'[Price] = _min
// )
// )
RETURN
IF ( _first = [Index], "Y", "N" )
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can try using RANKX instead of finding out the Minimum and assign Y when the rank is 1
This way you can probably solve the issue.
Proud to be a Super User!
User | Count |
---|---|
81 | |
75 | |
74 | |
42 | |
36 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |