Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Ilse_ScpDt
Helper I
Helper I

Sum month for all dates

Dear platform,

 

I have a measure that is always showing the MAX value. So if you group the days to a week you won't get 2+3+2+3+2 but you get the Max (in this case not 12 but 99). 

Ilse_ScpDt_1-1648135190086.png

 

I made the following (easy) measure to get the wanted 12:

 

PM_Needed_Present_week =
var ma = CALCULATE([PM_Needed_Present],DIM_Calendar[DutchDayName] = "Maandag")
var di = CALCULATE([PM_Needed_Present],DIM_Calendar[DutchDayName] = "Dinsdag")
var wo = CALCULATE([PM_Needed_Present],DIM_Calendar[DutchDayName] = "Woensdag")
var do = CALCULATE([PM_Needed_Present],DIM_Calendar[DutchDayName] = "Donderdag")
var vr = CALCULATE([PM_Needed_Present],DIM_Calendar[DutchDayName] = "Vrijdag")

return
ma + di + wo + do + vr
 
Ilse_ScpDt_3-1648135316747.png

 

How do I get the same measure for a month?

 

 

 

 

5 REPLIES 5
AlexisOlson
Super User
Super User

FYI, you can use an iterator to sum over the days:

PM_Needed_Present_week =
VAR _Days =
    FILTER (
        VALUES ( DIM_Calendar[DutchDayName] ),
        DIM_Calendar[DutchDayName] IN { "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag" }
    )
RETURN
    SUMX ( _Days, [PM_Needed_Present] )

If you want to sum over all days, then you can just write:

PM_Needed_Present_week =
SUMX (
    VALUES ( DIM_Calendar[DutchDayName] ),
    [PM_Needed_Present]
)

Thanks a lot! Also something I was looking for.

 

How would this work for the sum over a month instead of a week?

Same syntax but replace the day columns with the month column.

 

For example:

PM_Needed_Present_week =
VAR _Months =
    FILTER (
        VALUES ( DIM_Calendar[DutchMonthName] ),
        DIM_Calendar[DutchMonthName] IN { "mei", "juni", "juli" }
    )
RETURN
    SUMX ( _Months, [PM_Needed_Present] )
amitchandak
Super User
Super User

@Ilse_ScpDt , Assume this is a measure: PM_Needed_Present

A measure like

Maxx(Values(DIM_Calendar[DutchDayName]),[PM_Needed_Present])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks for the reply.

 

I am not looking for the maximum value, but trying to sum all values of the seperate days. For the week I can use the measures above. But how would it work for a month?

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.