Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Dear POWER BI Experts ,
I have the below Test Data :
CREATE TABLE Dax_Test_Product ( ProductID INT , UnitPrice INT )
INSERT INTO Dax_Test_Product VALUES ( 1 , 10)
INSERT INTO Dax_Test_Product VALUES ( 2 , 20)
INSERT INTO Dax_Test_Product VALUES ( 3 , 30)
INSERT INTO Dax_Test_Product VALUES ( 4 , 50)
INSERT INTO Dax_Test_Product VALUES ( 5 , 60)
INSERT INTO Dax_Test_Product VALUES ( 6 , 70)
INSERT INTO Dax_Test_Product VALUES ( 7 , 100)
INSERT INTO Dax_Test_Product VALUES ( 8 , 110)
INSERT INTO Dax_Test_Product VALUES ( 9 , 130)
INSERT INTO Dax_Test_Product VALUES ( 10 , 150)
INSERT INTO Dax_Test_Product VALUES ( 11 , 200)
INSERT INTO Dax_Test_Product VALUES ( 12 , 230)
INSERT INTO Dax_Test_Product VALUES ( 13 , 240)
INSERT INTO Dax_Test_Product VALUES ( 14 , 250)
INSERT INTO Dax_Test_Product VALUES ( 15 , 270)
INSERT INTO Dax_Test_Product VALUES ( 16 , 300)
The question -
Now If we want to Rank the products we can use the below formula -
Column_Rank = COUNTROWS(Filter(Dax_Test_Product,Dax_Test_Product[UnitPrice]<Earlier(Dax_Test_Product[UnitPrice])) ) +1
Now here , since I am using this in the calculated colums it is creating a new row context and then the filter also creates one another new row context , Could you please let me know how the row context created by the Filter actually takes place here?
I would also like to know about the context switches , how it happens .
Thanks in advance ,
Abhisek
Hi @Abhisek,
According to this MSDN document, we can know that Earlier() function returns the current value of the specified column in an outer evaluation pass of the mentioned column. And the Creating a Rank Value section in this article has described the method of calculation detailedly step by step.
As per my understanding, Earlier function works like cross join by itsefl. After cross join, the table expand to 16 x 16 rows, then, filter records based on a specific condition. In your table, there are 16 rows in the column, approximately a 16 x 16 operations will be required.
Besides, please refer to this article that will help you understand row context and earlier function more clearly.
Best regards,
Yuliana Gu
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |