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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ppdas2112
Helper I
Helper I

Total in Matrix Incorrect when using Measure with condition based on Today()

Hi experts!

Need your urgent help!

My data model is as below

ppdas2112_3-1650836643447.png

I have a simple measure: 

Actual/Forecast = IF(MONTH(MAX(DateTable[Date]))<MONTH(TODAY()),SUM(Actuals[Actuals]),SUM(Forecast[Forecast]))

When I plot this in Matrix, the total at Year level doesn't add up correctly. Kindly help!!

 

ppdas2112_4-1650836733138.png

@amitchandak @johnt75 @tamerj1 @Jihwan_Kim @PaulDBrown @truptis @Ashish_Mathur @AlexisOlson @parry2k @Greg_Deckler @BA_Pete @mahoneypat @Vera_33 @Vijay_A_Verma @edhans @jennratten @smpa01 @Thingsclump 

Thanks in advance!

 

3 ACCEPTED SOLUTIONS
Vera_33
Resident Rockstar
Resident Rockstar

Hi @ppdas2112 

 

It's calculation on different gran, you need a Month column in DateTable, guess you are using hierachy now

Actual/Forecast = 
IF (
    COUNTROWS ( ALLSELECTED ( DateTable ) ) = COUNTROWS ( DateTable ),
    SUMX (
        VALUES ( DateTable[Month] ),
        CALCULATE (
            IF (
                MAX ( DateTable[Month] ) < MONTH ( TODAY () ),
                SUM ( Actuals[Actuals] ),
                SUM ( Forecast[Forecast] )
            )
        )
    ),
    IF (
        MAX ( DateTable[Month] ) < MONTH ( TODAY () ),
        SUM ( Actuals[Actuals] ),
        SUM ( Forecast[Forecast] )
    )
)

View solution in original post

parry2k
Super User
Super User

@ppdas2112 here is the measure you need:

 

Actual/Forecast = 
SUMX ( 
   VALUES ( DateTable[Date] ),
   IF(MONTH(DateTable[Date])<MONTH(TODAY()),
        CALCULATE ( SUM(Actuals[Actuals]) ),
        CALCULATE ( SUM(Forecast[Forecast])
   )
)

 subscribe to my channel link below to learn why your original measure didn't work and what this measure is doing. I will be doing a video on this in the next few days.

 

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
parry2k
Super User
Super User

@ppdas2112 here is the measure you need:

 

Actual/Forecast = 
SUMX ( 
   VALUES ( DateTable[Date] ),
   IF(MONTH(DateTable[Date])<MONTH(TODAY()),
        CALCULATE ( SUM(Actuals[Actuals]) ),
        CALCULATE ( SUM(Forecast[Forecast])
   )
)

 subscribe to my channel link below to learn why your original measure didn't work and what this measure is doing. I will be doing a video on this in the next few days.

 

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k Thank you!!

Vera_33
Resident Rockstar
Resident Rockstar

Hi @ppdas2112 

 

It's calculation on different gran, you need a Month column in DateTable, guess you are using hierachy now

Actual/Forecast = 
IF (
    COUNTROWS ( ALLSELECTED ( DateTable ) ) = COUNTROWS ( DateTable ),
    SUMX (
        VALUES ( DateTable[Month] ),
        CALCULATE (
            IF (
                MAX ( DateTable[Month] ) < MONTH ( TODAY () ),
                SUM ( Actuals[Actuals] ),
                SUM ( Forecast[Forecast] )
            )
        )
    ),
    IF (
        MAX ( DateTable[Month] ) < MONTH ( TODAY () ),
        SUM ( Actuals[Actuals] ),
        SUM ( Forecast[Forecast] )
    )
)
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you @Ashish_Mathur !!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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