The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
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).
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
79 | |
71 | |
48 | |
39 |
User | Count |
---|---|
136 | |
108 | |
70 | |
64 | |
57 |