Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello everyone
I'm working with a KPI that should automatically show the current month's information (September) when no month is selected in the slicer.
The problem is that in the 3 KPIs at the bottom right, if I don't select a month, the values appear WHITE instead of updating with the current month.
On the other hand, if I select a month manually (for example, the current month), the KPIs work correctly and show the expected data.
I share with you below the example measure for the trend of Monthly Orders, which is representative of the ruling. The logic for daily KPIs is the same, with the difference that in those cases only yesterday is calculated against the same day of the previous year.
This one goes at the bottom:
Encargos_AñoPasado_HastaHoy =
VAR OpcionSeleccionada = SELECTEDVALUE(Seleccion_Rango_Fecha[Opcion], "Mes actual hasta hoy") -- Opción seleccionada
VAR FechaHoy = TODAY() - 1 -- Fecha actual
VAR MesSeleccionado = SELECTEDVALUE(MasterCalendar[Month Number]) -- Mes seleccionado (numérico)
-- Definir el rango de fechas para "Mes actual hasta hoy"
VAR FechaInicioAnioPasado = DATE(YEAR(FechaHoy) - 1, MONTH(FechaHoy), 1) -- Primer día del mes en el año pasado
VAR FechaLimiteAnioPasado = DATE(YEAR(FechaHoy) - 1, MONTH(FechaHoy), DAY(FechaHoy)) -- Mismo día del mes en el año pasado
VAR Resultado =
SWITCH(
TRUE(),
-- Si la opción seleccionada es "Mes actual hasta hoy"
OpcionSeleccionada="Mes actual hasta hoy",
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
EncargosAnx[fecha] >= FechaInicioAnioPasado,
EncargosAnx[fecha] <= FechaLimiteAnioPasado
),
-- Si la opción seleccionada es "Por meses"
OpcionSeleccionada="Por meses" && NOT ISBLANK(MesSeleccionado),
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
EncargosAnx[fecha] >= DATE(YEAR(TODAY()) - 1, MesSeleccionado, 1),
EncargosAnx[fecha] <= IF(
MesSeleccionado = MONTH(TODAY()),
FechaLimiteAnioPasado, -- Si el mes es el actual, hasta el mismo día del año pasado
EOMONTH(DATE(YEAR(TODAY()) - 1, MesSeleccionado, 1), 0) -- Si es otro mes, hasta el final del mes
)
),
BLANK() -- Si no se selecciona ninguna opción válida
)
RETURN
COALESCE(Resultado, 0)
This would go at the top:
Encargos_Mes_HastaHoy =
VAR OpcionSeleccionada = SELECTEDVALUE(Seleccion_Rango_Fecha[Opcion], "Mes actual hasta hoy") -- Opción seleccionada
VAR FechaHoy = TODAY() -- Fecha actual
VAR FechaInicioMesActual = DATE(YEAR(FechaHoy), MONTH(FechaHoy), 1) -- Primer día del mes actual
VAR FechaLimiteHoy = FechaHoy - 1 -- Hasta el día anterior a hoy
VAR MesSeleccionado = SELECTEDVALUE(MasterCalendar[Month Number]) -- Mes seleccionado
VAR AnioSeleccionado = YEAR(FechaHoy) -- Año actual
RETURN
SWITCH(
OpcionSeleccionada,
"Mes actual hasta hoy", -- Si se selecciona esta opción
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
EncargosAnx[fecha] >= FechaInicioMesActual, -- Desde el inicio del mes actual
EncargosAnx[fecha] <= FechaLimiteHoy, -- Hasta el día anterior a hoy
MasterCalendar[IsCurrentMonth] = 1
),
"Por meses", -- Si se selecciona "Por meses", realiza el cálculo para el mes seleccionado
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
MONTH(EncargosAnx[fecha]) = MesSeleccionado, -- Filtra por el mes seleccionado
YEAR(EncargosAnx[fecha]) = AnioSeleccionado -- Filtra por el año actual
),
BLANK() -- Si no se selecciona ninguna opción válida, muestra un valor en blanco
)
Thank you very much for any help
Solved! Go to Solution.
Try this:
Encargos_Mes_HastaHoy =
VAR OpcionSeleccionada = SELECTEDVALUE(Seleccion_Rango_Fecha[Opcion], "Mes actual hasta hoy") -- Opción seleccionada
VAR FechaHoy = TODAY() -- Fecha actual
VAR FechaInicioMesActual = DATE(YEAR(FechaHoy), MONTH(FechaHoy), 1) -- Primer día del mes actual
VAR FechaLimiteHoy = FechaHoy - 1 -- Hasta el día anterior a hoy
VAR MesSeleccionado = SELECTEDVALUE(MasterCalendar[Month Number]) -- Mes seleccionado
VAR AnioSeleccionado = YEAR(FechaHoy) -- Año actual
RETURN
SWITCH(
OpcionSeleccionada,
"Mes actual hasta hoy", -- Si se selecciona esta opción
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
EncargosAnx[fecha] >= FechaInicioMesActual, -- Desde el inicio del mes actual
EncargosAnx[fecha] <= FechaLimiteHoy, -- Hasta el día anterior a hoy
MasterCalendar[IsCurrentMonth] = 1
REMOVEFILTERS (MasterCalendar[Fecha])
),
"Por meses", -- Si se selecciona "Por meses", realiza el cálculo para el mes seleccionado
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
MONTH(EncargosAnx[fecha]) = MesSeleccionado, -- Filtra por el mes seleccionado
YEAR(EncargosAnx[fecha]) = AnioSeleccionado -- Filtra por el año actual
),
BLANK() -- Si no se selecciona ninguna opción válida, muestra un valor en blanco
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Syndicate_Admin ,
As we haven’t heard back from you, we wanted to kindly follow up to check if the suggestions provided by the community members for the issue worked. Please feel free to contact us if you have any further questions.
Thanks and regards
Hi @Syndicate_Admin ,
May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.
Thank you
Hi @Syndicate_Admin
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Thank you.
Hi,
Do you have a relationship between the EncargosAnx[fecha] and the MasterCalendar?
If you do you are getting the filter context from the calendar to get picked up from the slicer you add to the top in this case september, so you need to remove the filter context before calcution your values.
Try the following changes:
Encargos_AñoPasado_HastaHoy =
VAR OpcionSeleccionada = SELECTEDVALUE(Seleccion_Rango_Fecha[Opcion], "Mes actual hasta hoy") -- Opción seleccionada
VAR FechaHoy = TODAY() - 1 -- Fecha actual
VAR MesSeleccionado = SELECTEDVALUE(MasterCalendar[Month Number]) -- Mes seleccionado (numérico)
-- Definir el rango de fechas para "Mes actual hasta hoy"
VAR FechaInicioAnioPasado = DATE(YEAR(FechaHoy) - 1, MONTH(FechaHoy), 1) -- Primer día del mes en el año pasado
VAR FechaLimiteAnioPasado = DATE(YEAR(FechaHoy) - 1, MONTH(FechaHoy), DAY(FechaHoy)) -- Mismo día del mes en el año pasado
VAR Resultado =
SWITCH(
TRUE(),
-- Si la opción seleccionada es "Mes actual hasta hoy"
OpcionSeleccionada="Mes actual hasta hoy",
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
REMOVEFILTER(MasterCalendar[Date])
EncargosAnx[fecha] >= FechaInicioAnioPasado,
EncargosAnx[fecha] <= FechaLimiteAnioPasado
),
-- Si la opción seleccionada es "Por meses"
OpcionSeleccionada="Por meses" && NOT ISBLANK(MesSeleccionado),
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
EncargosAnx[fecha] >= DATE(YEAR(TODAY()) - 1, MesSeleccionado, 1),
EncargosAnx[fecha] <= IF(
MesSeleccionado = MONTH(TODAY()),
FechaLimiteAnioPasado, -- Si el mes es el actual, hasta el mismo día del año pasado
EOMONTH(DATE(YEAR(TODAY()) - 1, MesSeleccionado, 1), 0) -- Si es otro mes, hasta el final del mes
)
),
BLANK() -- Si no se selecciona ninguna opción válida
)
RETURN
COALESCE(Resultado, 0)
Let me know if this works if not can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.
If the information is sensitive please share it trough private message.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThis would be for the bottom, but for the top, what could I add ?
Thanks a lot
Try this:
Encargos_Mes_HastaHoy =
VAR OpcionSeleccionada = SELECTEDVALUE(Seleccion_Rango_Fecha[Opcion], "Mes actual hasta hoy") -- Opción seleccionada
VAR FechaHoy = TODAY() -- Fecha actual
VAR FechaInicioMesActual = DATE(YEAR(FechaHoy), MONTH(FechaHoy), 1) -- Primer día del mes actual
VAR FechaLimiteHoy = FechaHoy - 1 -- Hasta el día anterior a hoy
VAR MesSeleccionado = SELECTEDVALUE(MasterCalendar[Month Number]) -- Mes seleccionado
VAR AnioSeleccionado = YEAR(FechaHoy) -- Año actual
RETURN
SWITCH(
OpcionSeleccionada,
"Mes actual hasta hoy", -- Si se selecciona esta opción
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
EncargosAnx[fecha] >= FechaInicioMesActual, -- Desde el inicio del mes actual
EncargosAnx[fecha] <= FechaLimiteHoy, -- Hasta el día anterior a hoy
MasterCalendar[IsCurrentMonth] = 1
REMOVEFILTERS (MasterCalendar[Fecha])
),
"Por meses", -- Si se selecciona "Por meses", realiza el cálculo para el mes seleccionado
CALCULATE(
DISTINCTCOUNT(EncargosAnx[encargos_id]),
MONTH(EncargosAnx[fecha]) = MesSeleccionado, -- Filtra por el mes seleccionado
YEAR(EncargosAnx[fecha]) = AnioSeleccionado -- Filtra por el año actual
),
BLANK() -- Si no se selecciona ninguna opción válida, muestra un valor en blanco
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThe Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 46 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |