The DAX code calculating the sum of maximum values per day

后端 未结 1 1574
野的像风
野的像风 2021-01-21 13:30

I would like to write a dax code in Power BI which calculate the sum of maximum values of each day. In one column there is a production data and on the second column there is th

相关标签:
1条回答
  • 2021-01-21 14:06

    This will be a bit easier if you have a column that has just dates rather than datetime values. So first, create a calculated column (I'm assuming your table is called Data):

    DateDay = DATEVALUE(Data[Date])
    

    Now that we have that, let's write the measure.

    MaxValue =
    SUMX (
        SUMMARIZE ( Data, Data[DateDay], "MaxCount", MAX ( Data[Daily Counter] ) ),
        [MaxCount]
    )
    

    What this does is create a table that summarizes each day by taking the maximum count on each day. The SUMX then goes through each row in the summary table and adds up the maximum count for each day.

    Note that this works not just for the total, but on each row in your visual as well since the Data table that gets passed into the SUMMARIZE is filtered by its evaluation context so the DateDay filter is preserved.

    0 讨论(0)
提交回复
热议问题