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
Razorbx13
Post Patron
Post Patron

MTD Totals

Hello!  I have a P&L statement that allows users to go back in time to filter data based on a specific month end, then show MTD, YTD and Prior YTD totals as of that date.   As an example, I have a user select a filter of MONTH END, and they set it as "on or before" 9/30/2020.  Today is April 16th.  I have a join between my GL tables (MONTH END DATE) to my SQL Server Time table (CALENDAR DATE). 

 

Well the net totals of the DAX calculation below (1-9) are correct for each of the categories, but I am bringing in data from months other than 9/30/2020 in my MTD column which is representing months other than 9/30/2020.  If I filter for MONTH END "IS" 9/30/2020 everything is fine, but my YTD and PYTD are now off.  So how can I fix this?  The user could go back to say 11/30/2018 if they wanted.  And they filter on Month End, not a GL posting date.  So today they would set a filter of April 30, 2021.

 

BTW - I get the MTD to work if I hard code the Month (September) and Year (2020) into the FILTER below.   I also need that SWITCH command as well.

 

Thanks in advance.

 

 

MTD Actual = CALCULATE (    
    TOTALMTD (
    SWITCH ( [Row Selected Calc (SO)],
1,[Revenue (SO)],
2,[Cost of Sales (SO)],
3,[Gross Margin (SO)],
4,[Salary/Benefits (SO)],
5,[Other Expense (SO)],
6,[Net Income Before (SO)],
7,[Direct Allocations (SO)],
8,[Net Income After (SO)],
9,[Capital Expenditures (SO)] )
    ,'Time (GL Month End)'[Calendar Date]
    )   
     ,FILTER('GL Transactions (Statement of Operations)',[Account Type] = "ACTUAL")
    )
1 ACCEPTED SOLUTION

I think I got it working using the calculation below.  Notice the filter.

 

MTD Actual = CALCULATE (    
TOTALMTD (
    SWITCH ( [Row Selected Calc (SO)],
1,[Revenue (SO)],
2,[Cost of Sales (SO)],
3,[Gross Margin (SO)],
4,[Salary/Benefits (SO)],
5,[Other Expense (SO)],
6,[Net Income Before (SO)],
7,[Direct Allocations (SO)],
8,[Net Income After (SO)],
9,[Capital Expenditures (SO)] )
    ,'Time (GL Month End)'[Calendar Date]
    )   
     ,FILTER('GL Transactions (Statement of Operations)',[Month End] = MAX('Time (GL Month End)'[Month End]) && 'GL Transactions (Statement of Operations)'[Account Type]="ACTUAL")
    )

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Razorbx13 , Not very clear. Is this a date table and marked as date table in power BI

,'Time (GL Month End)'

 

 

Also, calculation group might be a better solution for this

https://www.youtube.com/watch?v=vlnx7QUVYME


https://www.sqlbi.com/blog/marco/2020/07/15/creating-calculation-groups-in-power-bi-desktop/

I think I got it working using the calculation below.  Notice the filter.

 

MTD Actual = CALCULATE (    
TOTALMTD (
    SWITCH ( [Row Selected Calc (SO)],
1,[Revenue (SO)],
2,[Cost of Sales (SO)],
3,[Gross Margin (SO)],
4,[Salary/Benefits (SO)],
5,[Other Expense (SO)],
6,[Net Income Before (SO)],
7,[Direct Allocations (SO)],
8,[Net Income After (SO)],
9,[Capital Expenditures (SO)] )
    ,'Time (GL Month End)'[Calendar Date]
    )   
     ,FILTER('GL Transactions (Statement of Operations)',[Month End] = MAX('Time (GL Month End)'[Month End]) && 'GL Transactions (Statement of Operations)'[Account Type]="ACTUAL")
    )

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.