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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
bendejnp
Helper I
Helper I

Using active and inactive in one measure

Hello,

 

Below is a simplified example of the dataset showing the orders with an order date and a date for requisted delivery. 

 

Example data:

bendejnp_0-1657722332950.png

 

order date and requested delivery date are connected with a calendar:

bendejnp_0-1657723901263.png

 

 

Now I need a measure that fullfils the following:

  • Turnover (month to date is important) summed up
  • with order date in current month (MTD)
  • with requested delivery in current month (MTD)

 

Until now I managed how to create a measure with either order date MTD or requested delivery date MTD (with userrelationshop to use the inactive connection), but not both at the same time. 

 

Can you guys help me?

1 ACCEPTED SOLUTION

OK, try

Turnover MTD = 
var mtd = DATESMTD( 'Calendar'[Date])
return CALCULATE( SUM('Table'[Turnover]),
REMOVEFILTERS('Calendar'),
TREATAS( mtd, 'Table'[Order date]),
TREATAS( mtd, 'Table'[Delivery date])
)

You may need to alter the REMOVEFILTERS if the order day & month aren't coming from the Calendar table.

View solution in original post

11 REPLIES 11
v-cazheng-msft
Community Support
Community Support

Hi @bendejnp ,

 

You may try this Measure.

Turnover MTD =
VAR Today_ =
    TODAY ()
VAR FirstDayOfMonth =
    DATE ( YEAR ( Today_ ), MONTH ( Today_ ), 1 )
RETURN
    CALCULATE (
        SUM ( 'Append'[Turnover] ),
        FILTER (
            'Append',
            'Append'[Order Date(YYYY/MM/DD)] >= FirstDayOfMonth
                && 'Append'[Requested Delivery Date(YYYY/MM/DD)] >= FirstDayOfMonth
        )
    )

 

Sample data:

vcazhengmsft_0-1658143741746.png

 

The result looks like this.

vcazhengmsft_1-1658143741747.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

johnt75
Super User
Super User

You could try

Turnover MTD = 
var mtd = DATESMTD( 'Calendar'[Date])
return CALCULATE( SUM('Table'[Turnover]),
TREATAS( mtd, 'Table'[Order date]),
TREATAS( mtd, 'Table'[Delivery date])
)

I tried it and it gives a figure, but it's much too low. Unfortunately I couldn't find out which part of data it slices. Any idea?

Try the below in DAX Studio

DEFINE
    VAR mtd =
        DATESMTD ( 'Calendar'[Date] )

EVALUATE
CALCULATETABLE (
    'Table',
    TREATAS ( mtd, 'Table'[Order date] ),
    TREATAS ( mtd, 'Table'[Delivery date] )
)

That will show the rows which are being summed up. If you compare that to the rows which you think should be included you might be able to see any critical differences

Update: Ok I found out it works only for the selected day, but it does not sum up month to date. So this part seems not to work:

var mtd = DATESMTD( 'Calendar'[Date])

 

Hmm, that could just be DAX Studio not having a context for the dates, where your report actually does.

Try

DEFINE
    VAR mtd =
        CALCULATETABLE (
            DATESMTD ( 'Calendar'[Date] ),
            TREATAS ( { TODAY () }, 'Calendar'[Date] )
        )

EVALUATE
CALCULATETABLE (
    'Table',
    TREATAS ( mtd, 'Table'[Order date] ),
    TREATAS ( mtd, 'Table'[Delivery date] )
)

Sorry my last post was not regarding DAX studio. I was typing whilst you already answered. I don't have DAX studio and cannot install on my business laptop.

However I found out the formula shows only the lines order date of the selected calendar day. Example:

bendejnp_0-1657726821277.png

The measure shows 435€, but it should shows 1690.

OK, try

Turnover MTD = 
var mtd = DATESMTD( 'Calendar'[Date])
return CALCULATE( SUM('Table'[Turnover]),
REMOVEFILTERS('Calendar'),
TREATAS( mtd, 'Table'[Order date]),
TREATAS( mtd, 'Table'[Delivery date])
)

You may need to alter the REMOVEFILTERS if the order day & month aren't coming from the Calendar table.

With the suggested change it works now. Thank you! 

However, I didn't understand which the "removefilter" has and why I have to use it here 😄

REMOVEFILTERS is to make sure that nothing is being filtered out by any slicers or filters applied to the calendar table.

Ok I see. So since the latest day is selected in the dashboard, it will only sum up the selected day. Thanks for the explanation.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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