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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Annu_choubey
Microsoft Employee
Microsoft Employee

¿Cómo escribir medida para obtener un recuento del valor en blanco para una fecha determinada?

Hola expertos,

Supongamos que tengo debajo de la tabla en la que tengo algún valor faltante en pocos días.

Valor de día Value
día 1 3
día2
day3
day4
día5
day6
día 7 8
día8 7
día9 8
day10
day11
day12 9

Como vemos arriba tenemos 5 días faltando valor desde el día 2 al día 6 y 2 día que falta desde el día 9 hasta el día 12.Necesidad de obtener el recuento de espacio en blanco en un día en particular.

Valor de día Valor esperado
día 1 3 3
día2 5
día 3 5
día4 5
día 5 5
día6 5
día7 8 8
día8 7 7
día9 8 8
día10 2
day11 2

day12 9 9


¿Cómo escribir medidas para obtener un recuento de espacio en blanco para un día determinado en Power BI?

Gracias
Annu

2 ACCEPTED SOLUTIONS

Tabla de origen "Recuento de en blanco"

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc/BCcAwCIXhXTwHoqZp4izB/ddoa2rp4YH/5UME1yKrUpWVqVCLvDyoiff01xqwA1gHdgIbaTPaOBNHtNHQpvDvpiYKwu8bi9wv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Day = _t, Value = _t, #"Expected value" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}, {"Expected value", Int64.Type}, {"Day", type date}})
in
    #"Changed Type"

Medida:

CountBlank := 
var d = SELECTEDVALUE('Count of Blank'[Day])
var v = SELECTEDVALUE('Count of Blank'[Value])
var cs = CALCULATE(max('Count of Blank'[Day]),'Count of Blank'[Value]<>BLANK(),'Count of Blank'[Day]<=d,ALLSELECTED('Count of Blank'))
var cf = CALCULATE(min('Count of Blank'[Day]),'Count of Blank'[Value]<>BLANK(),'Count of Blank'[Day]>=d,ALLSELECTED('Count of Blank'))
return if (ISBLANK(v),DATEDIFF(cs,cf,DAY)-1,v)

Resultado:

lbendlin_0-1601650089473.png

View solution in original post

Hola

Pruebe esta fórmula de columna calculada

=if(Data[Value]=BLANK(),CALCULATE(min(Data[Day]),FILTER(Data,Data[Value]>0&&Data[Day]>EARLIER([Day])))-(CALCULATE(MAX(Data[Day]),FILTER(Data,Data[Value]>0&&Data[Day]<EARLIER([Day])))+1),Data[Value])

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
v-diye-msft
Community Support
Community Support

Hola @Annu_choubey

Si la ayuda de las publicaciones anteriores, por favor márquela como una respuesta para ayudar a otros a encontrarla más rápidamente. ¡Gracias!

Si no, por favor, amablemente elaborar más.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Ashish_Mathur
Super User
Super User

Hola

En la columna Día, ¿tiene Day1, Day2 o tiene una entrada de fecha adecuada? Por favor, aclare.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hola ashish,

Gracias por la respuesta. fecha real El formato de la fecha es: 09/01/2020 (mm/dd/aaaa)

El día 1 comienza a partir del 09/01/2020

día 2 09/02/2020

...

día 12 09/12/2020

Déjame si necesitas algún detalle.

gracias de antemano

Hola

Pruebe esta fórmula de columna calculada

=if(Data[Value]=BLANK(),CALCULATE(min(Data[Day]),FILTER(Data,Data[Value]>0&&Data[Day]>EARLIER([Day])))-(CALCULATE(MAX(Data[Day]),FILTER(Data,Data[Value]>0&&Data[Day]<EARLIER([Day])))+1),Data[Value])

Espero que esto ayude.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Tabla de origen "Recuento de en blanco"

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc/BCcAwCIXhXTwHoqZp4izB/ddoa2rp4YH/5UME1yKrUpWVqVCLvDyoiff01xqwA1gHdgIbaTPaOBNHtNHQpvDvpiYKwu8bi9wv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Day = _t, Value = _t, #"Expected value" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}, {"Expected value", Int64.Type}, {"Day", type date}})
in
    #"Changed Type"

Medida:

CountBlank := 
var d = SELECTEDVALUE('Count of Blank'[Day])
var v = SELECTEDVALUE('Count of Blank'[Value])
var cs = CALCULATE(max('Count of Blank'[Day]),'Count of Blank'[Value]<>BLANK(),'Count of Blank'[Day]<=d,ALLSELECTED('Count of Blank'))
var cf = CALCULATE(min('Count of Blank'[Day]),'Count of Blank'[Value]<>BLANK(),'Count of Blank'[Day]>=d,ALLSELECTED('Count of Blank'))
return if (ISBLANK(v),DATEDIFF(cs,cf,DAY)-1,v)

Resultado:

lbendlin_0-1601650089473.png

lbendlin
Super User
Super User

Necesitas una columna que se pueda ordenar para eso. La columna Día de ejemplo no funciona para ese tipo. ¿Realmente está en ese formato o tienes fechas reales?

A continuación, puede utilizar FIRSTNONBLANK y LASTNONBLANK para encontrar los límites de sus huecos, etc.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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