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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
reportwriter001
Frequent Visitor

MTD Actual Compared to Monthly Budget

The Data Model

  1. DimDate Table
    1. Every day of the year
    2. Columns include:
      1. dimDateID
      2. DateName
  2. Actual YTD Units Sold
    1. We take snap shots on a weekly basis of our YTD sold units
    2. Includes a dimDateID
  3. Budgeted YTD Units by Month
    1. We budget what we expect our YTD sold units will be at the end of each month
    2. Includes dimDateID

The Problem Statement

Below is a screenshot of the current state of the data as of Dec 8, 2023.  I have budgeted and actual YTD unit numbers for Oct 31, 2023 and Nov 30, 2023.  No issues there.  I recently took a snapshot of our YTD unit numbers on Dec 7, 2023.  I need to compare the Dec 7, 2023 actual units with the Dec 31, 2023 budget.  I can't figure out how to write the DAX measure that says, "sum the Budget Units if the End of Month value for DateName in the Actuals table is equal to a DateName in the Budget table.

reportwriter001_0-1702076211838.png

 

Thank you in advance for any assistance.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create a solution for your semantic model.

 

Jihwan_Kim_1-1702104329207.png

 

Jihwan_Kim_0-1702104305499.png

 

Actual units measure: = 
VAR _monthcumulate =
    CALCULATE ( SUM ( Actual[actual_units] ), DATESMTD ( Dim_Date[Date] ) )
VAR _currentrowdate =
    MAX ( Dim_Date[Date] )
VAR _endofmonthdate =
    EOMONTH ( _currentrowdate, 0 )
VAR _conditiontable =
    FILTER (
        ADDCOLUMNS (
            FILTER ( ALL ( Dim_Date ), EOMONTH ( Dim_Date[Date], 0 ) = _endofmonthdate ),
            "@actualunits", CALCULATE ( SUM ( Actual[actual_units] ) )
        ),
        [@actualunits] <> BLANK ()
    )
VAR _conditionmaxdate =
    MAXX ( _conditiontable, Dim_Date[Date] )
RETURN
    SWITCH ( TRUE (), _conditionmaxdate = _currentrowdate, _monthcumulate )

 

 

Budget units measure: =
VAR _currentrowdate =
    MAX ( Dim_Date[Date] )
VAR _endofmonthdate =
    EOMONTH ( _currentrowdate, 0 )
VAR _budget =
    CALCULATE (
        SUM ( Budget[budgeted_units] ),
        TOPN (
            1,
            FILTER ( ALL ( Dim_Date ), EOMONTH ( Dim_Date[Date], 0 ) = _endofmonthdate ),
            CALCULATE ( SUM ( Budget[budgeted_units] ) )
        )
    )
RETURN
    IF ( NOT ISBLANK ( [Actual units measure:] ), _budget )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create a solution for your semantic model.

 

Jihwan_Kim_1-1702104329207.png

 

Jihwan_Kim_0-1702104305499.png

 

Actual units measure: = 
VAR _monthcumulate =
    CALCULATE ( SUM ( Actual[actual_units] ), DATESMTD ( Dim_Date[Date] ) )
VAR _currentrowdate =
    MAX ( Dim_Date[Date] )
VAR _endofmonthdate =
    EOMONTH ( _currentrowdate, 0 )
VAR _conditiontable =
    FILTER (
        ADDCOLUMNS (
            FILTER ( ALL ( Dim_Date ), EOMONTH ( Dim_Date[Date], 0 ) = _endofmonthdate ),
            "@actualunits", CALCULATE ( SUM ( Actual[actual_units] ) )
        ),
        [@actualunits] <> BLANK ()
    )
VAR _conditionmaxdate =
    MAXX ( _conditiontable, Dim_Date[Date] )
RETURN
    SWITCH ( TRUE (), _conditionmaxdate = _currentrowdate, _monthcumulate )

 

 

Budget units measure: =
VAR _currentrowdate =
    MAX ( Dim_Date[Date] )
VAR _endofmonthdate =
    EOMONTH ( _currentrowdate, 0 )
VAR _budget =
    CALCULATE (
        SUM ( Budget[budgeted_units] ),
        TOPN (
            1,
            FILTER ( ALL ( Dim_Date ), EOMONTH ( Dim_Date[Date], 0 ) = _endofmonthdate ),
            CALCULATE ( SUM ( Budget[budgeted_units] ) )
        )
    )
RETURN
    IF ( NOT ISBLANK ( [Actual units measure:] ), _budget )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks Jihwan.  This was spot on and extremely helpful.  Although my actuals are YTD and so I didn't need your actual measure, I was able to copy the budget measure and simply replace with my table/column names.  Thank you so much for your time and assistance on this.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors