Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Max value in a counting measure

Hello everyone I have two tables, an agenda and a production, I have two tb measurements, one that calculates the machine's production in the month and the other that calculates t...
  • v-alq-msft's avatar
    5 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 two measures as below.

    Count of Days = COUNTROWS('Table')

     

    Result = 
    var maxdays = 
    MAXX(
        SUMMARIZE(
            ALL('Table'),
            'Table'[Month],
            'Table'[Machine],
            "Count of Days",
            COUNTROWS('Table')
        ),
        [Count of Days]
    )
    var newtab = 
    ADDCOLUMNS(
        SUMMARIZE(
            'Table',
            'Table'[Month],
            'Table'[Machine],
            "Count",
            COUNTROWS('Table'),
            "TotalProduction",
            SUM('Table'[Production])
        ),
        "Result",
        DIVIDE(
           [TotalProduction],
           [Count]
        )*maxdays
    )
    return
    SUMX(
        newtab,
        [Result]
    )

     

    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.