Forum Discussion

MrWolle's avatar
MrWolle
Frequent Visitor
9 years ago

Performance compared to same period last year

Hello all,

 

I'm new to Power BI, actually new to DAX in general. I'm trying to create a Dashboard to track the utilization of trucks. For this i have designed an line chart showing the avg. utillization on years, per month per truck.

 

Beside this i have included a card showing YTD deviation from target, and a card showing YTD compared to same period last year. It all works until i beging to use the slicers that i have included in the Dashboard, then the YTD compared to last year wont work as figures showing up does not match actual figures.

 

Is here a friendly person to whom i could send my Dashboard, who would spend some time checking this?

 

If this it not allowed let me know, and i will try my best to describe it here instead.

 

As i said, i'm new to this so probably made some mistakes.

 

Thanks.

 

/Jens

5 Replies

  • Hi MrWolle

    please post the code of your DAX measures and maybe a screenshot of your dashboard and data model so we can advise.

    PS: we're all friendly here ;-)

    Frank

    • MrWolle's avatar
      MrWolle
      Frequent Visitor

      Hi BetterCallFrank,

       

      Thanks for your reply.

       

      I will try to explain, might get a little complicated though.

       

      My data period covers from 2015 to YTD, i have the following tables

      Date table covering from 2015 to 2025

      Delivery table were volume per delivery no. is used (table include other data)

      Shipment table showing shipment no. and included delivery numbers + loading date.

       

      Distinct count on shipments, shipment type 76 is excluded since these are combined shipments

      Distinct shipments = calculate(DISTINCTCOUNT(Shipments[Shipment]); Shipments[ST] <> 76)

       

      Summarize of CDM from deliveries and convert it to M3

      M3 calc = CALCULATE(SUM('Delivery data'[Volume corrected])/1000)

       

      Utillization per month calc

      Utillization per month = IFERROR('Delivery data'[M3 calc]/'Delivery data'[Distinct shipments];0)

       

      Accumulated utilization per year

      Utillization year = TOTALYTD([Utillization per month];'Date'[Date];DATESYTD(Shipments[ActShipEnd]))

       

      The above is used for this graph

      Next i calculate an accumulated year to date utililzation

      Year to date = calculate('Delivery data'[Utillization per month]; DATESYTD('Date'[Date]))

       

      And this is compared to target (40 m3) in this meassure

      Variance YTD target = 'Delivery data'[Year to date]/40-1

       

      Shown on this card on the Dashboard

       

      Next meassure should be showing variance  in utilization this year when compared to last year same period

       

      Calculate last year to date performance

      Same period last year m3 = Calculate([M3 calc];DATESBETWEEN('Date'[Date];"01-01-2016";DATEADD(LASTDATE(Shipments[ActShipEnd]);-1;YEAR)))

       

      Same period last year shipments = Calculate([Shipments YTD];DATESBETWEEN('Date'[Date];"01-01-2016";DATEADD(LASTDATE(Shipments[ActShipEnd]);-1;YEAR)))

       

      Shipments YTD = calculate(TOTALYTD([Distinct shipments];'Date'[Date]))

       

      Same period last year = [Same period last year m3]/[Same period last year shipments]

       

      Aaaand finaly the comparison meassure

      Variance last year = 'Delivery data'[Year to date]/'Delivery data'[Same period last year]-1

       

       

      Further more i have some slicers to select, shipping point, destination, truck type and transport planner, but when i use these the last measure last year vs. this year shows totally wrong numbers.

       

      As you can see on the meassures i'm really a beginner, and googled my way to most of this. Which means it can probably be made much easier.

       

      But i'm really struggeling to understand these time related DAX commands. Also tried with sameperiodlastyear, but couldn't get this to work.

       

      /Jens

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi MrWolle,

         

        >>But i'm really struggeling to understand these time related DAX commands. Also tried with sameperiodlastyear, but couldn't get this to work.

        These functions are used to filter with the specify date range, for example:

        TotalYTD function =

        Calculate(sum(Table[value]), Filter(Table, [Date]>=Date(current year,1,1) &&[Date]<=current Date))

         

        If you want to know more about these time fucntions, you can refer to bleow links:

        DAX basics in Power BI Desktop

        Data Analysis Expressions (DAX) Reference

         

        Regards,

        Xiaoxin Sheng