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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
luisccmm
Helper II
Helper II

Ventas de DatePicker entre con DAX

Hola

He hecho la aplicación adjunta PowerBI donde tengo lo siguiente:
Archivo Powerbi

- DatePicket establecido para seleccionar solo la fecha MAX.

- Tabla de calendario.

- Tabla contratos (fecha, columnas de número de contrato).

Estoy buscando construir una fórmula que si selecciono la fecha MAX de DatePicker mostrará los contratos de conteo desde la primera fecha en este año hasta la fecha seleccionada.

Para ello tengo construir tres funciones:

last_date = LASTDATE('Calendar'[Date])
first_date = date(year(LASTDATE('Calendar'[Date])),1,1)

dates_in_period = 
 CALCULATE(count(Contracts[Contract_id]),
 FILTER('Calendar','Calendar'[Date]>=[first_date]&&'Calendar'[Date]<=[last_date]))

El problema aquí es que si dejo caer esta medida con la dimensión del mes:

todavía hay valores en meses cuando deben establecerse en 0 o null.

Como en la imagen de abajo donde he establecido 21/04/2020 y hay valores de esta fecha en la que quiero ver null o .0.

date_contracts.png

Gracias de antemano!!!

1 ACCEPTED SOLUTION

@parry2k   Fourtanately after searching on the web I have found a solution for this problem in this article. The solution comes from creating another Calendar Table without any connection with the Data Model, and use this tables as Date Slicer, so even when is selected no filter is applied to the KPI. Then use variables as data imputs in measure that come from the Isolated Calendar Table ( in the slicer).

 

https://www.sqlservercentral.com/articles/how-to-override-date-filters-in-power-bi

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@luisccmm estás viendo los datos de forma incorrecta, en la selección de fecha tienes una fecha de 2010 y tienes datos para 2019, si los miras por mes, también te mostrará 2019 meses. así es como supone que funciona.

image.png

Consulta mi última entrada de blog Año-2020, Pandemia, Power BI y más allá para obtener un resumen de mis versiones favoritas de las características de Power BI en 2020

Me gustaría elogios si mi solución ayudara. 👉 Si puedes dedicar tiempo a publicar la pregunta, también puedes hacer esfuerzos para dar Felicitaciones a quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos en https://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hola @parry2k sé lo que hay en el panel Filtro de fecha.

Pero todavía has visto la Fórmula que he escrito en el Post cuidadosamente, ¿Cómo es que soy período de tiempo limitado desde el 1 de enero 2020 hasta la fecha máxima del calendario y estoy recibiendo valores antes de ese intervalo?.

Estoy tratando de lograr esto y me parece que está bien planeado, pero el resultado no es el esperado.

last_date = LASTDATE('Calendar'[Date])
first_date = date(year(LASTDATE('Calendar'[Date])),1,1)

dates_in_period = 
 CALCULATE(count(Contracts[Contract_id]),
 FILTER('Calendar','Calendar'[Date]>=[first_date]&&'Calendar'[Date]<=[last_date]))
parry2k
Super User
Super User

@luisccmm por qué no utilizar la función DATESYTD

Contract Count YTD = 
 CALCULATE(
count(Contracts[Contract_id]),
DATESYTD ( 'Calendar'[Date] )
)

Consulta mi última entrada de blog Año-2020, Pandemia, Power BI y más allá para obtener un resumen de mis versiones favoritas de las características de Power BI en 2020

Me gustaría elogios si mi solución ayudara. 👉 Si puedes dedicar tiempo a publicar la pregunta, también puedes hacer esfuerzos para dar Felicitaciones a quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos en https://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k   Fourtanately after searching on the web I have found a solution for this problem in this article. The solution comes from creating another Calendar Table without any connection with the Data Model, and use this tables as Date Slicer, so even when is selected no filter is applied to the KPI. Then use variables as data imputs in measure that come from the Isolated Calendar Table ( in the slicer).

 

https://www.sqlservercentral.com/articles/how-to-override-date-filters-in-power-bi

@parry2k Sigue viendo valores en los meses siguientes cuando uso DATESYTD

APP está aquí si alguien quiere intentarlo.

https://drive.google.com/file/d/1Dm2qU2lkJMsGgtJmdQ3nbZ-UXk-Jq388/view?usp=sharing

data_contract 2.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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