The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello all,
I am fairly new to PowerBI and more specifically - DAX.I would like to know the following : is there a way to generate a column using DAX formula which takes the values of only the last 3 rows from another column? I will attach a screenshot of the expected result below.
Thanks in advance for your help!
Hi:
Maybe you can add an index column on this table via Power Query. TRANSFORM>ADD NEW COLUMN > INDEX COLUMN > Index from 1. The last three in your example are index 6-8. I'll call your table "Data".
Then you can do an IF statement.
Result = IF(Data[Index] IN { 6, 7, 8}, Data[Value], BLANK()).
You can also use TOPN to make a table.
Bottom 3 Index Values = TOPN(3, VALUES(Data[Value]),
CALCULATE(SUM(Data[Index])),
DESC
)
I hope this helps solve your question..
The index will be always changing.I think I didnt provide the right example,here is a better one :
User | Count |
---|---|
27 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
7 | |
6 |