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! Learn more

Reply
rpinxt
Solution Sage
Solution Sage

3 different formulas with same outcome....why?

I have these measures :

Prod_ACT = [Actual] / [FTE_ACT]

 

Prod_Ytd_ACT = CALCULATE([Prod_ACT],DATESYTD(Dim_Date[Date]),VALUES(Dim_Date[Period]))

 

Prod_Ytd_ACT2 = TOTALYTD([Prod_ACT],Dim_Date[Date].[Date])

 

But they give me all 3 the same amount every month :

rpinxt_0-1663923989543.png

 

Why are the 2 with Ytd still breaking down on period?

I don't want them to break up to field Period.

I want them to add up all previous periods from that year.

1 ACCEPTED SOLUTION

@rpinxt Try this:

Measure = 
    VAR __Date = MAX(Dim_Date[Date])
    VAR __Year = MAX('Dim_Date'[Year])
    VAR __Table = 
        SUMMARIZE(
            FILTER(
                ALL('Dim_Date'),
                [Date] <= __Date && [Year] = __Year
            ),
            [Period],
            "__Prod_ACT",[Prod_ACT]
        )
RETURN
    AVERAGEX(__Table,[__Prod_ACT])


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...

View solution in original post

9 REPLIES 9
rpinxt
Solution Sage
Solution Sage

@Greg_Deckler @Anonymous 
Thanks guys for your help.
However no luck:

rpinxt_0-1663926783116.png

Greg his formula still refuses to add up periods.

And the measure of dax_noob is doing somehting strange.

Changing DESC to ASC did not help it.

@rpinxt Post sample source data as text please. It's just pure guesswork otherwise. This video may help though: https://youtu.be/meh3OkgFYfc

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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...

@Greg_Deckler I understand Greg. Made a simpler new model for myself to check the logics but there they work.....

 

It is a rather complicated (for me) model but I put in on Google Drive for you to have a look at.

Saw that that was also a possibility to share my file with you so here is the link:

https://drive.google.com/file/d/1vQAq2eifdjwul0bE6Un7OPQmfDvPpKd2/view?usp=sharing

 

And what I try to achieve is actually what is in the green column below :

rpinxt_0-1663930163426.png

 

@rpinxt Try this:

Measure = 
    VAR __Date = MAX(Dim_Date[Date])
    VAR __Year = MAX('Dim_Date'[Year])
    VAR __Table = 
        SUMMARIZE(
            FILTER(
                ALL('Dim_Date'),
                [Date] <= __Date && [Year] = __Year
            ),
            [Period],
            "__Prod_ACT",[Prod_ACT]
        )
RETURN
    AVERAGEX(__Table,[__Prod_ACT])


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...

@Greg_Deckler amazing....spot on 😁👍

Code looks not straight forward...what would be the bottleneck in my model causing all these troubles (because with standard formulas it would not work)?

 

Also just for my knowledge could it also return the YTD amount?

Probably it is there somewhere in the logic.

@rpinxt Should be to just use the same code and do a SUMX instead of an AVERAGEX.



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...

Thanks! Learned a lot todayy 😁

Anonymous
Not applicable

@rpinxt 

try this

Prod_Ytd_ACT =
VAR maxdate =
    MAX ( Dim_date[Date] )
RETURN
    CALCULATE (
        [Prod_ACT],
        ALL ( Dim_date ),
        ISONORAFTER ( Dim_date[Date], maxdate, DESC )
    )


BR

Greg_Deckler
Community Champion
Community Champion

@rpinxt Eschewing a long diatribe about CALCULATE and TI functions, try this:

Measure = 
  VAR __Period = MAX('Table'[Period])
  VAR __Table = ADDCOLUMNS(FILTER('Table',[Period] <= __Period),"__Prod_ACT",[Prod_ACT])
RETURN
  SUMX(__Table,[__Prod_ACT])


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...

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