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
ExcelMonke
Resolver I
Resolver I

TOTALMTD Behaviour, Date Column Context

Hello,

I am currently scratching my head at how:

  1. The TOTALMTD function is behaving in this scenario, and
  2. How do I fix this?

I currently have the following measure:

 

IF(TOTALMTD([Measure],DateDim[Date]),>x,"Provider Meets Criteria","")

 

The expected result is that it only looks at the current month (Currently it is Feb-2024). I am expecting blanks for all other months before Feb-2024.

Not only is the result not what I'm expecting, but it is not consistent.

ExcelMonke_0-1709250161870.png

In the reference snapshot, I would expect all of the providers to either have:
1) "Provider Meets Criteria" in all columns from when it meets criteria. E.g. in row 5, column 1/1/2024 should not be blank, OR, all columns prior to that should be blank
2) OR, only have column 2/1 populate with "Provider Meets Criteria"

 

Thanks!

1 ACCEPTED SOLUTION
RossEdwards
Solution Specialist
Solution Specialist

The measure works on the provided filter context.  So in your example, your columns are providing the filter context of the different months.

Instead you'll want to change the filter context of the TOTALMTD to look at the date values of the current month.  A common solution here might be to have a column in your date table that flags what the current month records are. 

From here you could update your measure to be:

IF(
    CALCULATE(
        TOTALMTD([Measure],DateDim[Date]),
        ALL(DateDim),
        DateDim[CurrentMonth]
    ) > x,
    "Provider Meets Criteria",
    ""
)

(This assumes the 'CurrentMonth' column is a true/false column

View solution in original post

3 REPLIES 3
v-tangjie-msft
Community Support
Community Support

Hi @ExcelMonke ,

 

Thanks @RossEdwards  for the quick reply and solution.

I have another solution for you to consider.

 

Your current measure is

Measure=IF(TOTALMTD([Measure],DateDim[Date])>x,"Provider Meets Criteria","")

Then we can create a new measure.

Measure 2 = IF(MONTH(SELECTEDVALUE('Table'[date]) )=MONTH(TODAY()) && YEAR(SELECTEDVALUE('Table'[date]))=YEAR(TODAY()),[Measure],BLANK())

Note that since the columns on my matrix place the date field of the table table, I use 'Table'[date] in the dax, if you are placing the date field of the date table on your matrix, change it to 'DimDate'[date].

 

Then place [Measure 2] on the values of the matrix.

vtangjiemsft_0-1709261732923.png

vtangjiemsft_1-1709261841237.png

 

Best Regards,

Neeko Tang

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

RossEdwards
Solution Specialist
Solution Specialist

The measure works on the provided filter context.  So in your example, your columns are providing the filter context of the different months.

Instead you'll want to change the filter context of the TOTALMTD to look at the date values of the current month.  A common solution here might be to have a column in your date table that flags what the current month records are. 

From here you could update your measure to be:

IF(
    CALCULATE(
        TOTALMTD([Measure],DateDim[Date]),
        ALL(DateDim),
        DateDim[CurrentMonth]
    ) > x,
    "Provider Meets Criteria",
    ""
)

(This assumes the 'CurrentMonth' column is a true/false column

Thank you, this helped solve my issue! 

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.