Forum Discussion

eduardo's avatar
eduardo
Advocate II
9 years ago
Solved

date issue

First of all: Happy 2017 I'm needing help with basic dates concepts: I have several campaigns that are repeated throughout the year. Each has a start date and a end date. ex. Campaign - Date - ...
  • BetterCallFrank's avatar
    BetterCallFrank
    9 years ago

    Hi eduardo,

     

    had a look at your PBIX - i think you should invest some more time into data modelling, i.e. create dimensions for flights/campaigns/redes and so on.

    Start and end dates of campaigns are not "clean" i.e. more than one start date for some campaigns etc.

     

    As for A):

    storing this information in a calculated column as you did is just fine.

    If you want it in a measure you can do it with this DAX

    ..Duration = CALCULATE( DATEDIFF( MAX( fDados[data_inicio] ),  MAX( fDados[data_fim] ), DAY ))

    For column you can define default summarization method to "count" - if thats really what you need, although I'm not sure. If you set this setting to "count" for this column you wont have to change it from "SUM" every time.

     

    As for B)

    You can do this with a measure like

    ..Days Elapsed = DATEDIFF( MAX( fDados[data_inicio] ), TODAY(), DAY )

    As for C)

    it's not clear to me, what exactly you want to compare -

    Running total of CPA could be in a measure like

    ..RunningCPA = 
    VAR MaxDate = MAX( DimDate[Date] )
    RETURN
    CALCULATE( [.CPA], 
      ALL( DimDate[Date] ),
      DimDate[Date] <= MaxDate
    )

    but as I said its not entirely clear to me - e.g. in order to determine what is the "previous flight" the flight-dimension would need some kind of "order" or something (look at PBIX file below).

     

    I made some adjustments to your PBIX, you can find it here:

    https://dl.dropboxusercontent.com/u/2676210/Mapa%20de%20Campanhas_Novo.pbix

     

    Maybe this helps your understanding a little, let me know where you stand after having a look.

     

    HTH,

    Frank