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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Measure to sum data for first available month of every year

Hi, I am relatively new to PowerBI and DAX programming (although I have been working on Tabular Cubes a little bit).

 

Anyway, I want to create a measure which will have sum(field) for the first available month of the year.

 

The table below should help to understand better.

 

Thanks to all of you in advance.

 

PeriodSUM(Field) for a monthDESIRED OUTPUT: SUM(Field) for first available month of the year (MIN)
2018-115656
2018-125156
2019-018585
2019-021285
2019-036585
2019-042485
2019-058785
2019-061585
2019-076385
2019-083885
2019-091785
2019-109985
2019-111885
2019-121785
2020-013333
2020-024133

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

I created a [Year] column and a [Month] column first;

 

Year = [Period].[Year]
Month = [Period].[MonthNo] 

 

Then, I create a [Sum_Field] measure;

 

Sum_Field = 
CALCULATE(
    SUM(Sheet1[Field]),
    ALLEXCEPT(
        Sheet1,
        Sheet1[Year], Sheet1[Month]
    )
) 

 

At last, I wrote a measure referring to @Greg_Deckler‘s answer;

 

Measure 2 = 
VAR x = MAX(Sheet1[Year])
VAR y = FILTER(ALL(Sheet1), Sheet1[Year] = x)
var z = MINX(y, Sheet1[Month])
RETURN
SUMX(
    FILTER( y, Sheet1[Month] = z),
    [Sum_Field]
)

 

cc1.PNGcc2.PNG

 

Best regards,
Lionel Chen

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

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

I did it like this:

PBIX is attached. 

Measure = 
    VAR __Year = YEAR(MAX('Table'[Period]))
    VAR __Table = FILTER(ALL('Table'),YEAR('Table'[Period]) = __Year)
    VAR __Min = MONTH(MINX(__Table,[Period]))
RETURN
    SUMX(
        FILTER(__Table,MONTH([Period]) = __Min),
        [Field]
    )

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi, it worked like a charm for total, however, if I add some filter (narrow down data), new measure shows total (not narrowed down as all other measures). Maybe there is a small twerk to change it so that it would work on whichever filters I would apply?

Anonymous
Not applicable

Create year column and month column.

Then create table

Table = SUMMARIZE(Sheet3,Sheet3[Year],"Month",MIN(Sheet3[Month]))
 
Create amount column in table as 
amount = LOOKUPVALUE(Sheet3[Amount],Sheet3[Month],'Table'[Month],Sheet3[Year],'Table'[Year])
 
Then join sheet3 and table on year column.
And drag amount column from table and year and month from sheet3.
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

 

ibarrau
Super User
Super User

Hi, what a nice unusual question haha. Let me see. The measure I'll show you will only work if you add it in a visualization with the Date (period column). Otherwise you should mention your objetive for the visualization or we should consider using a column instead of measure.

Try this:

Measure =
VAR year_actual_line = YEAR(MAX(Table[Period]))
RETURN
CALCULATE (
    SUM ( Table[Field]) ) ,
    YEAR( Table[Period] ) = year_actual_line ,
    MONTH ( Table[Period] ) = 1
)

 

Hope I get the idea and this works,

Regards,


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

Happy to help!

LaDataWeb Blog

Anonymous
Not applicable

Hi, your suggested solution showed data only for the first month, I added ALLEXECPT( ) filter, it fixed it, BUT

 

if I add some filter (narrow down data), new measure shows total (not narrowed down as all other measures). Maybe there is a small twerk to change it so that it would work on whichever filters I would apply?

Hi @Anonymous ,

 

I created a [Year] column and a [Month] column first;

 

Year = [Period].[Year]
Month = [Period].[MonthNo] 

 

Then, I create a [Sum_Field] measure;

 

Sum_Field = 
CALCULATE(
    SUM(Sheet1[Field]),
    ALLEXCEPT(
        Sheet1,
        Sheet1[Year], Sheet1[Month]
    )
) 

 

At last, I wrote a measure referring to @Greg_Deckler‘s answer;

 

Measure 2 = 
VAR x = MAX(Sheet1[Year])
VAR y = FILTER(ALL(Sheet1), Sheet1[Year] = x)
var z = MINX(y, Sheet1[Month])
RETURN
SUMX(
    FILTER( y, Sheet1[Month] = z),
    [Sum_Field]
)

 

cc1.PNGcc2.PNG

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

You can try the solution which i have posted.

Thanks
Pravin

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors