Forum Discussion
Row Index
Hi friends,
I would like to achieve this using DAX. I have achieved this actually credits one of our friends here who provided the correct DAX.
But I needed to change something.
In the image is what I want to get. I already got to create a row sequence if they have the same value of Column 1 using the DAX below. Now I want to add a parameter to put a sequence based on the Column 2.
JofrainVisda Not sure why you need to get so complicated with your original formula, you can do the same thing like this:
Column Row Easy = VAR __Index = [Index] VAR __Mod = MOD([Index], 3) VAR __Table = ADDCOLUMNS('vw_AssignedChecklist2 (2)', "__ModColumn", MOD([Index], 3)) VAR __Return = COUNTROWS(FILTER( __Table, [__ModColumn] = __Mod && [Index] <= __Index)) RETURN __ReturnFor the other one, you can do this:
Seq Column 2 = VAR __Value = [Column2] VAR __Values = DISTINCT('vw_AssignedChecklist2 (2)'[Column2]) VAR __Path = CONCATENATEX(__Values, [Column2], "|",[Index]) VAR __Count = COUNTROWS(__Values) VAR __Table = ADDCOLUMNS( GENERATESERIES(1, __Count, 1), "__Item", PATHITEM( __Path, [Value], TEXT) ) VAR __Return = MAXX(FILTER(__Table, [__Item] = __Value), [Value]) RETURN __ReturnPBIX is attached below signature.
2 Replies
- AmiraBedh
Super User
Try :
Column Row = ROWNUMBER( SUMMARIZE( ALLSELECTED('vw_AssignedChecklist2 (2)'), 'vw_AssignedChecklist2 (2)'[Column 2], // Partition by Column 2 'vw_AssignedChecklist2 (2)'[Column 1], // Then by Column 1 "Index", 'vw_AssignedChecklist2 (2)'[Index] // Include Index for ordering within partitions ), ORDERBY('vw_AssignedChecklist2 (2)'[Column 2], ASC, 'vw_AssignedChecklist2 (2)'[Column 1], ASC, 'vw_AssignedChecklist2 (2)'[Index], ASC), // Order by Column 2, then Column 1, then Index DEFAULT, PARTITIONBY('vw_AssignedChecklist2 (2)'[Column 2], 'vw_AssignedChecklist2 (2)'[Column 1]) // Partition by both Column 2 and Column 1 ) - Greg_Deckler
Community Champion
JofrainVisda Not sure why you need to get so complicated with your original formula, you can do the same thing like this:
Column Row Easy = VAR __Index = [Index] VAR __Mod = MOD([Index], 3) VAR __Table = ADDCOLUMNS('vw_AssignedChecklist2 (2)', "__ModColumn", MOD([Index], 3)) VAR __Return = COUNTROWS(FILTER( __Table, [__ModColumn] = __Mod && [Index] <= __Index)) RETURN __ReturnFor the other one, you can do this:
Seq Column 2 = VAR __Value = [Column2] VAR __Values = DISTINCT('vw_AssignedChecklist2 (2)'[Column2]) VAR __Path = CONCATENATEX(__Values, [Column2], "|",[Index]) VAR __Count = COUNTROWS(__Values) VAR __Table = ADDCOLUMNS( GENERATESERIES(1, __Count, 1), "__Item", PATHITEM( __Path, [Value], TEXT) ) VAR __Return = MAXX(FILTER(__Table, [__Item] = __Value), [Value]) RETURN __ReturnPBIX is attached below signature.