Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hey hello,
Situation:
Species name | Index | Outcome needed |
human | 1 | 1 |
horse | 2 | 1 |
fish | 3 | 1 |
human | 4 | 2 |
centaur | 5 | 1 |
fish | 6 | 2 |
fish | 7 | 3 |
I only found suggestions in dax using 'EARLIER', which doesn't exist anymore and should be replaced with SELECTEDVALUE. Right? But I don't get it working:
Outcome =
VAR _Selected = SELECTEDVALUE(Data[species name])
RETURN
RANKX(
FILTER(
Data, Data[species name] = _Selected ),
Data[Index], ,
ASC
)
Solved! Go to Solution.
Try the following :
Outcome =
CALCULATE (
COUNTROWS ( Data ),
FILTER (
Data,
Data[species name] = EARLIER ( Data[species name] )
&& Data[Index] <= EARLIER ( Data[Index] )
)
)
Hi @Joris_NL ,
I create a table as you mentioned.
Then I create a Calculated column and it gives me the result you want. Here is the DAX code.
Outcome =
VAR CurrentIndex = 'Data'[Index]
VAR CurrentSpecies = 'Data'[Species name]
RETURN
CALCULATE (
COUNT ( 'Data'[Index] ),
FILTER (
ALL ( 'Data' ),
'Data'[Index] <= CurrentIndex
&& 'Data'[Species name] = CurrentSpecies
)
)
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Joris_NL ,
I create a table as you mentioned.
Then I create a Calculated column and it gives me the result you want. Here is the DAX code.
Outcome =
VAR CurrentIndex = 'Data'[Index]
VAR CurrentSpecies = 'Data'[Species name]
RETURN
CALCULATE (
COUNT ( 'Data'[Index] ),
FILTER (
ALL ( 'Data' ),
'Data'[Index] <= CurrentIndex
&& 'Data'[Species name] = CurrentSpecies
)
)
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Try the following :
Outcome =
CALCULATE (
COUNTROWS ( Data ),
FILTER (
Data,
Data[species name] = EARLIER ( Data[species name] )
&& Data[Index] <= EARLIER ( Data[Index] )
)
)
Thank you very much. Both suggestions work perfectly but this one, with EARLIER, calculates instantly while the sollution with variables takes about 15 seconds (though only once during refresh).
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
116 | |
101 | |
87 | |
35 | |
35 |
User | Count |
---|---|
152 | |
100 | |
83 | |
63 | |
54 |