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