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
Chris03_
Frequent Visitor

Datos anteriores a una fecha

Buenas... necesito saber como hacer para al elegir un intervalo de fechas (por ejemplo de una semana especifica) en el segmentador, en una tabla/matriz me salgan los valores de 1 semana antes al intervalo de fechas elegida en el segmentador. Desde ya muchas gracias, si pueden ayudarme por favor.

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

Hi @Chris03_ ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1711095658876.png
Create a new date table

Date = VALUES('Table'[Date])

Use the Date[Date] as the value of slicer

vheqmsft_1-1711095874779.png

 

Create measures

MaxDate = 
IF(
    SELECTEDVALUE('Table'[Date]) <= MAX('Date'[Date]) - 7,
    1,
    0
)
MinDate = 
IF(
    SELECTEDVALUE('Table'[Date]) >= MIN('Date'[Date]) -7,
    1,
    0
)

Use Table[Date] as table value and Apply measure to filter

vheqmsft_2-1711095936631.png

Final output

vheqmsft_3-1711095962611.png

If you want to change the date interval dynamically, i.e., instead of a week, you can create another measure to replace the fixed 7

DateRange = DATEDIFF(MIN('Date'[Date]),MAX('Date'[Date]),DAY)+1

 

Best regards,

Albert He

 

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

6 REPLIES 6
v-heq-msft
Community Support
Community Support

Hi @Chris03_ ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1711095658876.png
Create a new date table

Date = VALUES('Table'[Date])

Use the Date[Date] as the value of slicer

vheqmsft_1-1711095874779.png

 

Create measures

MaxDate = 
IF(
    SELECTEDVALUE('Table'[Date]) <= MAX('Date'[Date]) - 7,
    1,
    0
)
MinDate = 
IF(
    SELECTEDVALUE('Table'[Date]) >= MIN('Date'[Date]) -7,
    1,
    0
)

Use Table[Date] as table value and Apply measure to filter

vheqmsft_2-1711095936631.png

Final output

vheqmsft_3-1711095962611.png

If you want to change the date interval dynamically, i.e., instead of a week, you can create another measure to replace the fixed 7

DateRange = DATEDIFF(MIN('Date'[Date]),MAX('Date'[Date]),DAY)+1

 

Best regards,

Albert He

 

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





 

lbendlin
Super User
Super User

DATEADD(xxx,-7,DAYS)

Lo intente, pero no da el resultado deseado. Busco hacer una medida, que al poner en una matriz y utilice un segmentador de fecha para elejir un intervalo de fechas (una semana) en la matriz se reflejen valores pero de 7 dias antes. 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

 

 

Chris03__0-1710519310149.png

En la foto se observa los datos obtenidos al filtrar entre las fechas 17/02 y 23/02. Lo que necesito es que al realizar ese filtro, es que esa medida Peso 1 Med me de el valor pero de lo obtenido 1 semana antes es decir, del 10 al 16. El datediff no me sirvio.

Second request: Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors