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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
nandobaeza97
Regular Visitor

Calculo de importe si una fecha es anterior a otra fecha seleccionada en objeto visual (filtro)

Buenas tardes,

estoy intentando calcular el importe total si la fecha de este importe es anterior al último día de la fecha que se está seleccionando en un filtro de fechas.

El problema está cuando tengo que comparar una columna fecha con la medida que realiza el cálculo de la fecha fin que se esté seleccionando en el filtro.

¿Como podría realizar esta comparación? He intentado cambiar la medida y hacerlo en una columna, pero el valor de fecha fin seleccionada es distinta a la medida, no se ejecuta bien como es lógico.

¿Alguna idea?

Muchas gracias de antemano!

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi @nandobaeza97 ,

I created some data:

Table:

vyangliumsft_0-1667195129734.png

Slicer_Date:

vyangliumsft_1-1667195129734.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _mindate=MINX(ALLSELECTED(Slicer_Date),[Date])
var _maxdate=MAXX(ALLSELECTED('Slicer_Date'),[Date])
return
IF(
    MAX('Table'[Date]) <_maxdate,1,0)
Measure =
SUMX(ALLSELECTED('Table'),[Amount])

2. Place [Flag]in Filters, set is=1, apply filter.

Displays data smaller than the Slicer selection max date

vyangliumsft_2-1667195129736.png

3. Result:

vyangliumsft_3-1667195129743.png

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi @nandobaeza97 ,

I created some data:

Table:

vyangliumsft_0-1667195129734.png

Slicer_Date:

vyangliumsft_1-1667195129734.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _mindate=MINX(ALLSELECTED(Slicer_Date),[Date])
var _maxdate=MAXX(ALLSELECTED('Slicer_Date'),[Date])
return
IF(
    MAX('Table'[Date]) <_maxdate,1,0)
Measure =
SUMX(ALLSELECTED('Table'),[Amount])

2. Place [Flag]in Filters, set is=1, apply filter.

Displays data smaller than the Slicer selection max date

vyangliumsft_2-1667195129736.png

3. Result:

vyangliumsft_3-1667195129743.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@nandobaeza97 , Assumed you are using a date table

 

new measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = maxx(filter(all(Table),Table[Date] <_max) , Table[Date]
return
calculate( sum(Table[Value]), filter(all('Date'), 'Date'[Date] =_min))

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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