Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Getting the sum of maximum distinct values

Hi,    I have the data in the below format.   Storenumber FW Period CUST Sales OP 1 FW2 PRE REP 12356 1 FW2 PRE NEW 12356 1 FW3 PRE ...
  • v-alq-msft's avatar
    6 years ago

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table:

     

    You may create a measure as below.

    Result = 
    var tab =
    GROUPBY(
        'Table',
        'Table'[Storenumber],
        'Table'[FW],
        'Table'[Period],
        "Max",MAXX(CURRENTGROUP(),'Table'[Sales OP])
    )
    
    return
    DIVIDE(
        SUMX(
            FILTER(
                tab,
                [Period]="PRE"
            ),
            [Max]
        ),
        SUMX(
            FILTER(
                tab,
                [Period]="POST"
            ),
            [Max]
        )
    )

     

    Result:

     

    Best Regards

    Allan

     

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