Forum Discussion
Translate the dax code to evaluate in Dax studio
Please may I have help know How should the below calulated column be coded in dax studio
If you need to add a calculated column showing the prices that pass the filter for each row, please use the following code in dax studio or in the powerbi query view. Please note that nested tables are not accepted in a cell of a powerbi table, therefore the value presented is a concatenation of the values in the field (you may not be able to see all the values included in the concatanation due to string constraints in that cell)
If I responded to your query, please bookmark the post as a solution. Kudos 😀 are acceptedDEFINE COLUMN 'Product'[NewCalculatedColum] = VAR PriceOfCurrentProduct = 'Product'[Unit Price] VAR MoreExpensiveProducts = FILTER ( 'Product', 'Product'[Unit Price] > PriceOfCurrentProduct ) RETURN CONCATENATEX ( MoreExpensiveProducts, 'Product'[Unit Price], UNICHAR ( 10 ), 'Product'[Unit Price], DESC ) EVALUATE Product ORDER BY Product[Unit Price] DESC
14 Replies
- anmolmalviya05
Super User
Hi , Please try below solution:
EVALUATE
ADDCOLUMNS(
'Product',
"ProductRankDense",
VAR currentrow = 'Product'[Unit Price]
RETURN
COUNTROWS(
FILTER(
VALUES('Product'[Unit Price]),
'Product'[Unit Price] > currentrow
)
) + 1
)
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!Let's Connect on LinkedIn: https://www.linkedin.com/in/anmol-malviya/?originalSubdomain=in
Subscribe my youtube channel for Microsoft Fabric and Power BI updates: https://www.youtube.com/@AnmolPowerBICorner
- han_rj
Helper IV
Thanks for helping, The main part I wanted to translate was the Filter table generated
As highlighted I want to view the table that is been generaed as a result of Filter logic
- anmolmalviya05
Super User
Please try this:
EVALUATE
ADDCOLUMNS(
VALUES('Product'[Unit Price]),
"FilteredTable",
CALCULATETABLE(
VALUES('Product'[Unit Price]),
'Product'[Unit Price] > 'Product'[Unit Price]
)
)
- Syndicate_Admin
Administrator
If you need to add a calculated column showing the prices that pass the filter for each row, please use the following code in dax studio or in the powerbi query view. Please note that nested tables are not accepted in a cell of a powerbi table, therefore the value presented is a concatenation of the values in the field (you may not be able to see all the values included in the concatanation due to string constraints in that cell)
If I responded to your query, please bookmark the post as a solution. Kudos 😀 are acceptedDEFINE COLUMN 'Product'[NewCalculatedColum] = VAR PriceOfCurrentProduct = 'Product'[Unit Price] VAR MoreExpensiveProducts = FILTER ( 'Product', 'Product'[Unit Price] > PriceOfCurrentProduct ) RETURN CONCATENATEX ( MoreExpensiveProducts, 'Product'[Unit Price], UNICHAR ( 10 ), 'Product'[Unit Price], DESC ) EVALUATE Product ORDER BY Product[Unit Price] DESC - AnonymousNot applicable
Hi han_rj ,
If you want to view the table generated by the filtering logic, you can use the ADDCOLUMNS function to create a temporary table containing the results of the filtering.FilteredTable = VAR currentrow = 'Product'[Unit Price] RETURN ADDCOLUMNS( FILTER( ALL('Product'), 'Product'[Unit Price] > currentrow ), "Filtered Unit Price", 'Product'[Unit Price] )Best regards,
Albert HeIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- han_rj
Helper IV
Hi, Thank You for helping but I hit this error when I tried the attached code
- AnonymousNot applicable
Hi han_rj ,
Create a calculate table instead of a measure.
Best regards,
Albert HeIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Syndicate_Admin
Administrator
If you want to add a calculated column that includes the data that passes the filter for each row of the original table, please try the following code in dax studio or in the dax query view.
Please if I answered your query accept the solution, kudos 😀 are acceptedDEFINE COLUMN 'Product'[NewCalculatedColum] = VAR PriceOfCurrentProduct = 'Product'[Unit Price] VAR MoreExpensiveProducts = FILTER ( 'Product', 'Product'[Unit Price] > PriceOfCurrentProduct ) RETURN CONCATENATEX ( MoreExpensiveProducts, 'Product'[Unit Price], UNICHAR ( 10 ) ) EVALUATE Product