Forum Discussion

chadg's avatar
chadg
Regular Visitor
1 year ago
Solved

Grouping records in table visual

I have a table visual in a report with a list of work items that are sorted by Job# and User Name. I am trying to create a lotting system for quality control that groups each set of work items into groups of 10.

 

I created the following dax code in a visual calculation to count to 10 and revert to 1, but it does not check if there are changes in the Job# or User Name column. My current work around is to use a slicer to select one job and user to prevent the numbering from not resetting when it is supposed to. I'm not currently doing anything to prevent each item from moving around other than sorting the visual by the date it was completed. Each item does have a sequential key in the background that could be used for this.

 

Calculation = 1

 

Calculation 1 = RUNNINGSUM([Calculation])

 

Weld Lot = SWITCH(CALCULATE(RIGHT(SUBSTITUTE(SELECTEDVALUE([Calculation 1]),".00",""),1),OFFSET(-1)), "1","2", "2","3", "3","4", "4","5", "5","6", "6","7", "7","8", "8","9", "9","10", "1")
 
The data in the visual should appear as below:
 
Work Item IDJob NumberUser NameCalculationCalculation 1Weld Lot
1491234John Doe1.001.001
6821234John Doe1.002.002
2501234Jack Smith1.003.001
8791234Jack Smith1.004.002
1239876John Doe1.005.001
4569876John Doe1.006.002
7895678Jane Doe1.007.001
8915678Jane Doe1.008.002
9025678Jane Doe1.009.003
1055678Jane Doe1.0010.004
1145678Jane Doe1.0011.005
125678Jane Doe1.0012.006
185678Jane Doe1.0013.007
48755678Jane Doe1.0014.008
1545678Jane Doe1.0015.009
6275678Jane Doe1.0016.0010
4355678Jane Doe1.0017.001
8905678Jane Doe1.0018.002

 

It currently looks like this:

 

Work Item IDJob NumberUser NameCalculationCalculation 1Weld Lot
1491234John Doe1.001.001
6821234John Doe1.002.002
2501234Jack Smith1.003.003
8791234Jack Smith1.004.004
1239876John Doe1.005.005
4569876John Doe1.006.006
7895678Jane Doe1.007.007
8915678Jane Doe1.008.008
9025678Jane Doe1.009.009
1055678Jane Doe1.0010.0010
1145678Jane Doe1.0011.001
125678Jane Doe1.0012.002
185678Jane Doe1.0013.003
48755678Jane Doe1.0014.004
1545678Jane Doe1.0015.005
6275678Jane Doe1.0016.006
4355678Jane Doe1.0017.007
8905678Jane Doe1.0018.008

 

The Weld Lot counting should reset under 3 conditions: change in Job#, change in user name, or previous weld lot = 10. 

 

I would also like to be able to export the data from the visual into excel, but visual calculations are a preview feature and they do not allow exporting. If there is a way around that, I would appreciate that as well.

 

Thank you for your help

  • Hi,

    I have used a combination of Power Query and a DAC calculated column formula to solve the problem (though this can be solved in Power Query only as well).

    PBI file attached.

    Hope this helps.

     

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, chadg 

    Based on your information, I create a sample table:

     

    Then create calculated columns:

    Calculation = 1
    Calculation 1 = 
    SUMX(
        FILTER(
            'Table',
            'Table'[Index] <= EARLIER('Table'[Index])
        ),
        'Table'[Calculation]
    )
    
    Weld Lot = 
    VAR _Rank = RANKX(
        FILTER(
            'Table',
            'Table'[User Name] = EARLIER('Table'[User Name])
        ),
        'Table'[Index],
        ,
        ASC,
        DENSE
    )
    RETURN
        IF(
            ISBLANK(_Rank) || MOD(_Rank, 10) = 0,
            10,
           MOD(_Rank,10)
        
    )

     

    Here is my preview:

     

    How to Get Your Question Answered Quickly

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • chadg's avatar
      chadg
      Regular Visitor

      Anonymous Thank you for your help.

       

      In your second picture, index 5 and 6 are given lot number 3 and 4. They should be 1 and 2 because the user name is the same, but the job number changed. Can you help with that?

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        I have used a combination of Power Query and a DAC calculated column formula to solve the problem (though this can be solved in Power Query only as well).

        PBI file attached.

        Hope this helps.