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
pamsardinha
Frequent Visitor

EOMONTH not returning some values

Hi!

I have two measures I created to calculate the difference of Saldo between months.

 

First one is calculating the saldo of end of month:

 

 

SaldoEOM = 
VAR Latest_Date = MAX('Table1'[Date])
RETURN
    CALCULATE (SUM('Table1'[Saldo]), 'Table1'[Date] = Latest_Date)

 

 

 

Second one is getting the saldo of end of month from previous month:

 

 

SaldoEPM =
CALCULATE(SUM('Table1'[Saldo]),
        'Table1'[Date] = EOMONTH(max('Table1'[Date]),-1),
        ALLEXCEPT('Table1', 'Table1'[Saldo], 'Table1'[Date], 'Table2'[System],  'Table3'[variable1],'Table4'[variable1]))

 

 

  

Third one is calculating the difference between them:

 

 

SaldoChange = [SaldoEOM] - [SaldoEPM]

 

 

 

The result looks like this:

YearMonthSaldoEPMSaldoEOMSaldoChangeSystem
2023Jan01010A
2023Feb102010A
2023Mar2012-8A
2023Apr12153A
2023May15205A
2023Jun205030A
2023Jan06565O
2023Feb6542-23O
2023Mar429553O
2023Apr9556-39O
2023May5652-4O
2023Jun 5050O

 

The problem is the SaldoEPM in the last line (Jun) for system "O" is not getting the value 52, as it should (like for system "A" 20).

I appreciate the help!

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Create a Calendar Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name by the Month number
  2. Create a relationship (Many to One and Single) from the Date column of Table1 to the Date column of the Calendar Table
  3. To your visual, drag Year and Month name from the Calendar Table
  4. Write these measures

Total = sum('Table1'[Saldo])

Total in pm = calculate([total],previousmonth(calendar[date]))

Variance = [Total in pm]-[Total]

Hope this helps.


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

Hi @Ashish_Mathur 

Thank you for your reply. Unfortunately I cannot create Calendar table as I am working with PowerBI datasets and I do not have the rights to create them.
In any case, I appreciate your input, but if you have any other suggestions, that will be awesome as well.
Thank you,
Pamela.

v-xinruzhu-msft
Community Support
Community Support

Hi @pamsardinha 

1. Please check if there is data for the date column 5/31 in the "o" type in your table, the current return is empty may have no data for the date column 5/31 last month, or there is no number 5/31 in the date column.

2.You can try the following measure

 

 

SaldoEPM =
CALCULATE (
    SUM ( 'Table1'[Saldo] ),
    FILTER (
        ALLSELECTED ( 'Table1' ),
        'Table1'[Date] = EOMONTH ( MAX ( 'Table1'[Date] ), -1 )
            && [System] IN VALUES ( 'Table2'[System] )
    )
)

 

 

 

Best Regards!

Yolo Zhu

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

 

Hi @v-xinruzhu-msft 

 

Thank you for your reply.

I tried with your measure and it returns the same error...
I am sure that there is value at end of 31/5 because I can see in the calculate column SaldoEOM (in my example is 52 for system O).
If you have any other suggestion, I appreciate.

Thank you,

Pamela.

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.