Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Blank Year over Year Column

Hello,   I am relatively new to Power BI so I'm still fumbling through it.  I've tried to use a technique from another post, however, I continue to have an issue. As far as I can tell I have follow...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Make sure your column Shipments[Date] is of type date value!

     

    If you don't want to work with a separate date table and relate that table to your fact table you can still make it work by doing this instead:

    Use Shipments[Date] directly in your visualization instead of using the calculations YEAR(..) and MONTH(...)

    Power BI will create a date hierarchy for you automatically. 

    Change the meassure for RevLastYear to: CALCULATE([SumRevenue],DATEADD(Shipments[Date].[Date],-1,YEAR))

     

    That should give you what you are looking for.

     

    Br,

    Magnus

     

     

  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi Anonymous,

     

    You can use below formula to get the previous years' total.

     

    Pervious Year Total =
    var currDate=MAX([Date])
    return
    SUMX(FILTER(ALL(Shipments),Shipments[Date]>=DATE(YEAR(currDate)-1,1,1)&&Shipments[Date]<=DATE(YEAR(currDate)-1,12,31)&&MONTH([Date])=MONTH(currDate)),[Total Revenue])

     

    Pervious Year(Month/Year) =
    SUMX(FILTER(ALL(Shipments),Shipments[Date]>=DATE(MAX([Year])-1,1,1)&&Shipments[Date]<=DATE(MAX([Year])-1,12,31)&&[Month]=MAX([Month])),[Total Revenue])

     

    Result:

     

    Regards,

    Xiaoxin Sheng