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
MauroBote
Helper I
Helper I

Generar registro de fecha con valor 0 en caso de no existir fecha

Hola.
Tengo una tabla con las columnas tipo de producto, monto de la venta y fecha de la venta, la cual debo graficarla como una linea con los montos acumulados por fecha. Este grafico debe poder filtrarse por tipo de producto y rango de fechas calendario, para lo cual genere un tabla de calendario.

Mi problema se presenta en que si uno en el rango de fecha selecciona una fecha inicial y una fecha final, si la fecha inicial no existe en la tabla debe graficarla en el grafico como 0 y mantenerlo hasta llegar al punto del monto de la primera fecha de venta incluida en el rango seleccionado. Por otro lado la fecha final, en caso de no existir, debe graficarse tambien manteniendo el monto acumulado de la ultima venta registrada en el rango de fechas seleccionado.

¿Como puedo hacer para generar este grafico correctamente con los valores 0 cuando no existe venta?

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @MauroBote ,

 

Based on my test, the best way I can think of at the moment is "+0".

You can add "+0" in your measure. For example,

Measure = SUM('Table'[sale amount])+0

vstephenmsft_0-1652166459495.png

Neither April 17 nor May 31 are listed in the Sales Date column of the main table. The disadvantage is that other dates that are not in the sales date column are all 0.

 

 

 

Best Regards,

Stephen Tao

 

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

 

Thanks Stephen Tao!
It doesn't work for me because when I add the 0, the graphic show al dates (as amount 0) and not only the selected dates on slicer.
The problem of the 0 between the selected dates on slicer no matter because I'm doing a running total formula for the amounts.
If there is a way to restringe the grapich just for selected dates on slicer, it would be a perfect solution.

MauroBote
Helper I
Helper I

Thanks, but it doesn´t work. Actually I have already this formula and doesn't show the initial date on the graphic:

 

CALCULATE(
    SUM(HITOS[MONTO]),
    USERELATIONSHIP(CALENDARIO[Date],HITOS[FECHA]),FILTER(
        ALLSELECTED(CALENDARIO[Date]),
        MAX(CALENDARIO[Date])<=(HITOS[FECHA])&&ISONORAFTER(CALENDARIO[Date], MAX(CALENDARIO[Date]), DESC)
    )

Any other idea?
amitchandak
Super User
Super User

@MauroBote , Check if a measure like this can help

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))

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.