Forum Discussion

andyor's avatar
andyor
Resolver I
3 years ago
Solved

Calculating Turnover with a split

I have several rows in my dataset where the Turnover field needs to be split up into 3/4/5/6/7 parts, depending.    The issue I face is that if say the turnover is $200 and I need to split it into ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi andyor ,

    Please try below steps:

    1. below is my test table

    Table:

    2. create a measure and add it to table visual

    Avg Tuno =
    VAR cur_id =
        SELECTEDVALUE ( 'Table'[ID] )
    VAR tmp =
        FILTER ( ALL ( 'Table' ), 'Table'[ID] = cur_id )
    VAR ctn =
        COUNTROWS ( tmp )
    VAR max_tuno =
        MAXX ( tmp, [Turnover] )
    RETURN
        DIVIDE ( max_tuno, ctn )
    
    Measure =
    VAR cur_id =
        SELECTEDVALUE ( 'Table'[ID] )
    VAR tmp =
        FILTER ( ALL ( 'Table' ), 'Table'[ID] = cur_id )
    VAR max_tuno =
        MAXX ( tmp, [Turnover] )
    VAR ctn =
        COUNTROWS ( tmp )
    VAR _a =
        FORMAT ( [Avg Tuno], "0.00" )
    VAR diff = ctn * _a - max_tuno
    RETURN
        IF (
            diff > 0,
            IF ( SELECTEDVALUE ( 'Table'[RecordType] ) = 1, _a - diff, _a ),
            IF ( SELECTEDVALUE ( 'Table'[RecordType] ) = 1, _a + diff, _a )
        )
    

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.