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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Joshua_
Helper II
Helper II

Help with the date filter

Hi Guys,

I need to calculate the sales per month between 2 dates, I created in the calendar table two columns with the maximum date and the minimum date, I also created a measure with the datebetween function with the dates but the result is the accumulated sales and it should be shown per month .

measure Saldo=

VAR INI = SELECTEDVALUE(CALENDARIO[INICIO_HISTORICO])
VAR FIN = SELECTEDVALUE(CALENDARIO[FIN_HISTORICO])

RETURN


CALCULATE(
[Saldo_Prom],
DATESBETWEEN(CALENDARIO[Date],INI,FIN)

)



table.png

any suggestions, thanks guys.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Does it do what you expect if you use KEEPFILTERS to prevent DATESBETWEEN from overriding the month?

 

Saldo =
VAR INI = SELECTEDVALUE ( CALENDARIO[INICIO_HISTORICO] )
VAR FIN = SELECTEDVALUE ( CALENDARIO[FIN_HISTORICO] )
RETURN
    CALCULATE (
        [Saldo_Prom],
        KEEPFILTERS ( DATESBETWEEN ( CALENDARIO[Date], INI, FIN ) )
    )

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

Does it do what you expect if you use KEEPFILTERS to prevent DATESBETWEEN from overriding the month?

 

Saldo =
VAR INI = SELECTEDVALUE ( CALENDARIO[INICIO_HISTORICO] )
VAR FIN = SELECTEDVALUE ( CALENDARIO[FIN_HISTORICO] )
RETURN
    CALCULATE (
        [Saldo_Prom],
        KEEPFILTERS ( DATESBETWEEN ( CALENDARIO[Date], INI, FIN ) )
    )

It was just what I needed, thank you very much @AlexisOlson 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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