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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DatesMTD showing wrong calculation

I have written this formula which includes DatesMTD. However, it's showing an incorrect calculation.

 

Test = CALCULATE(SUM(GOALS_CONSOLIDATED[MONTHLY_GOAL]), GOALS_CONSOLIDATED[GOAL_NAME] = "TRx (Dispensed) Count Goal", GOALS_CONSOLIDATED[BRAND] = "ABC", DATESMTD(GOALS_CONSOLIDATED[Date]))
 
Instead of showing 3668 as the answer which is the goal for the current month(August), it is showing a value 8041 which is the goal for the month of December. Can anyone let me know where I'm going wrong.  
1 ACCEPTED SOLUTION

For Quarter :- 

Test =
CALCULATE (
    SUM ( GOALS_CONSOLIDATED[MONTHLY_GOAL] ),
    GOALS_CONSOLIDATED[GOAL_NAME] = "TRx (Dispensed) Count Goal",
    GOALS_CONSOLIDATED[BRAND] = "ABC",
    QUARTER( GOALS_CONSOLIDATED[Date] ) = QUARTER ( NOW () )
)

 

For year :-

CALCULATE (
    SUM ( GOALS_CONSOLIDATED[MONTHLY_GOAL] ),
    GOALS_CONSOLIDATED[GOAL_NAME] = "TRx (Dispensed) Count Goal",
    GOALS_CONSOLIDATED[BRAND] = "ABC",
    Year( GOALS_CONSOLIDATED[Date] ) = Year ( NOW () )
)

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

9 REPLIES 9
Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

Do you have calender table/date table which connected to GOALS_CONSOLIDATED table if yes then pass date column from calender/date table into DatesMTD function.

 

Thank you,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Tried what you said but it still isn't giving the correct answer

Can you try below code:- 

 

Test =
CALCULATE (
    SUM ( GOALS_CONSOLIDATED[MONTHLY_GOAL] ),
    GOALS_CONSOLIDATED[GOAL_NAME] = "TRx (Dispensed) Count Goal",
    GOALS_CONSOLIDATED[BRAND] = "ABC",
    MONTH ( GOALS_CONSOLIDATED[Date] ) = MONTH ( NOW () )
)

 

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

That's working. Can you tell me how the calcualtion would be for QTD and YTD?

For Quarter :- 

Test =
CALCULATE (
    SUM ( GOALS_CONSOLIDATED[MONTHLY_GOAL] ),
    GOALS_CONSOLIDATED[GOAL_NAME] = "TRx (Dispensed) Count Goal",
    GOALS_CONSOLIDATED[BRAND] = "ABC",
    QUARTER( GOALS_CONSOLIDATED[Date] ) = QUARTER ( NOW () )
)

 

For year :-

CALCULATE (
    SUM ( GOALS_CONSOLIDATED[MONTHLY_GOAL] ),
    GOALS_CONSOLIDATED[GOAL_NAME] = "TRx (Dispensed) Count Goal",
    GOALS_CONSOLIDATED[BRAND] = "ABC",
    Year( GOALS_CONSOLIDATED[Date] ) = Year ( NOW () )
)

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Took some time to reply as I got pulled into a meeting but yes this works! Thankns!

Greg_Deckler
Super User
Super User

@Anonymous Hard to say with the information provided. But I wouldn't use TI functions.

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008


@ 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!:
The Definitive Guide to Power Query (M)

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

Hi Greg, I went through the link you provided but didn't understand what you wanted to convey. If you have a solution for the month to date, can you write how the formula will be in my case? Thakns

Anonymous
Not applicable

In your 2nd link, I see a formula written for YTD but there's no formula for MTD and QTD 😞

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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