Forum Discussion
custom index for column
- 2 years ago
Hi, Anonymous
You can use DAX RANKX() func to achieve you goal.
refer: https://learn.microsoft.com/en-us/dax/rankx-function-dax
sample DAX idea:
Custom Index = VAR CurrentLogicalID = [Logical ID] VAR CurrentDynamic = [Dynamic] VAR StaticCount = COUNTROWS(FILTER(YourTable, YourTable[Dynamic] = "False")) RETURN IF(CurrentDynamic = "False", "False", StaticCount + RANKX(FILTER(YourTable, YourTable[Dynamic] = "True"), [Logical ID], , ASC) + 5)also I found some thread that would help you give idea,
Anonymous
First, create a new column in your table that contains the index values for the dynamic objects.
You can do this by using the Table.SelectRows function to select the rows where the object is dynamic and then using the List.Numbers function to generate a list of index values starting from 6 up to 10 (or any other value you want).
You can then use the Table.AddColumn function to add this new column to your table.
Next, create another new column that will contain the final index values for each row.
You can do this by using the Table.AddColumn function again to add a custom column that applies a custom function to each row of your table.
The function should check if the object is dynamic or not and then return either the value of the new column (if it is dynamic) or the original index value (if it is static).
For example :
let
Source = <your data source>,
#"Added Custom" = Table.AddColumn(Source, "DynamicIndex", each if [Dynamic] then List.Numbers(6, 5) else null),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "DynamicIndex"),
#"Added Custom1" = Table.AddColumn(#"Expanded Custom", "FinalIndex", each if [Dynamic] then [DynamicIndex] else [Index] + 1)
in
#"Added Custom1"
This will output a new table with two additional columns: DynamicIndex and FinalIndex.
The DynamicIndex column contains the index values for the dynamic objects, and the FinalIndex column contains the final index values for each row based on whether it is dynamic or not.