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
Anonymous
Not applicable

Values on cero for year over yaer measure

Hi everyone! i hope you can help me with this.

I dont know if is a issue or not but here is the problem:

im trying to take the % of variation of the value called "ProdGWh" for 2021 vs 2020.

Here the values

value.PNG

and this is the table idea that i want

idea.PNG

the question is, why in my report show like this, all the values in cero?

Captura.PNG

Im using this dax calculation: 

 

YoY% de ProdGWh =
IF(
    ISFILTERED('Calendario'[Fecha]),
    ERROR("La medida rápida de inteligencia de tiempo solo se puede agrupar o filtrar mediante la jerarquía de datos proporcionada por Power BI o por la columna de datos principal."),
    VAR __PREV_YEAR =
        CALCULATE(
            SUM('vw_producciondiaria'[ProdGWh]),
            DATEADD('Calendario'[Fecha].[Date], -1, YEAR)
        )
    RETURN
        DIVIDE(SUM('vw_producciondiaria'[ProdGWh]) - __PREV_YEAR, __PREV_YEAR)
)

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

i have to do measures manually like first the YTD, next the Previous Year and next the divide of this too. Now works! 

PY2 =
Var Anio = MAX(Calendario[Año])
Var LYAnio = Anio-2
Return
CALCULATE(SUM('vw_producciondiaria'[ProdGWh]),Calendario[Año]=LYAnio)
---------------------------------------- ---------------------------------------------
YTD2 =
Var Anio = MAX(Calendario[Año])
Var LYAnio = Anio -1
Return
CALCULATE(SUM('vw_producciondiaria'[ProdGWh]),Calendario[Año]=LYAnio)
------------------------------------------------------------------------------------
% Growth2 = IF([PY2]==0,0,DIVIDE([YTD2]-[PY2],[PY2],0)+1)
-----------------------------------------------------------------------------------
the only thing is that i have to change my calendar query years manually for this to work.
Thanks !!

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

i have to do measures manually like first the YTD, next the Previous Year and next the divide of this too. Now works! 

PY2 =
Var Anio = MAX(Calendario[Año])
Var LYAnio = Anio-2
Return
CALCULATE(SUM('vw_producciondiaria'[ProdGWh]),Calendario[Año]=LYAnio)
---------------------------------------- ---------------------------------------------
YTD2 =
Var Anio = MAX(Calendario[Año])
Var LYAnio = Anio -1
Return
CALCULATE(SUM('vw_producciondiaria'[ProdGWh]),Calendario[Año]=LYAnio)
------------------------------------------------------------------------------------
% Growth2 = IF([PY2]==0,0,DIVIDE([YTD2]-[PY2],[PY2],0)+1)
-----------------------------------------------------------------------------------
the only thing is that i have to change my calendar query years manually for this to work.
Thanks !!
Anonymous
Not applicable

Look @amitchandak  is weird that i put the measure in a new page without nothing else in a matrix table and the value is 0.00 too. Maybe is something wrong in the measure? 

Captura.PNG

How can i get the porcentage of this value "ProdGwh" for 2021 vs 2020 ?? maybe there is another way to do it.

@Anonymous , if the new page has no date selected. And you are using time intelligence, Date will first/last date of the table you have passed to the time intelligence function. 

Also, avoid using .date, .year etc. Use functions like year([Date]) 

Anonymous
Not applicable

Hi! thanks for your answer, but the tables have not timestap.

Respect this "do not use .[Date] unless date has a time stamp." if i change the Date for year o whatever then i get a measure error. 😕

Thanks!

amitchandak
Super User
Super User

@Anonymous , do not use .[Date] unless date has a time stamp.

You need to make sure both calendar table and table joined on dates and dates on both sides do not have a time stamp.

 

 

if the date in vw_producciondiaria having time stamp  then create date first and then join with date table

Date = [datetime].date
or
Date = date(year([datetime]),month([datetime]),day([datetime]))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

refer why TI fails : https://www.youtube.com/watch?v=OBf0rjpp5Hw&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L&index=3

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.