Forum Discussion
2 date fields in different table
- 10 years ago
- 10 years ago
having a calendar table makes your life much easier (because you get to use the time intelligence functions)
you can do those calculations without it but you'll have to write a bit more
look here at this link provided by Matt
http://www.powerpivotpro.com/2015/02/create-a-custom-calendar-in-power-query/
Maybe one of those is a cumulative/running total? Why is the difference so much?
Try creating Runing Totals for each like so
Forecast RT = CALCULATE ( SUM(Table[Forecast], FILTER(ALL(Table), Table[Date] <=MaX(Table[Date]) ) )
Actual RT = CALCULATE ( SUM(Table[Actual], FILTER(ALL(Table), Table[Date]<=MAX(Table[Date]) ) )
I'll try that but to answer your question, depending the date I select, one will show and dupicate the total.
So if I select the date under forecast, I will have the forcast per day with no probelem and the impression served will be the total of all impressions, if I select the date under Impression served, I will have the impressions per day with no prob and the forecast will be the total forecasted impressions :(
- elatreille10 years agoHelper I
Wow, this is the first time I am seeing this in Excel! So no choice, the solution is to create a middle table that links the dates in both table. Thanks to both of you!
Eric
- Greg_Deckler10 years agoCommunity Champion
I'm pretty sure that if you create a table of just dates and relate both Impressions and Forecast to it like in my model, you will get the correct lines.
Here is what is going on, it just dawned on me. Because there is no relationship between Forecast and Impressions, it is doing exactly what you said, it is simply summing one or the other (all of them) for every date because there is no context filter for date essentially. So the aggregation gets everything. That is why one is so much higher than the other and why it is the same number for all dates.
- elatreille10 years agoHelper I
I am sure it will work if I create a table with the field "date" and add all dates in it but it does't make sense.
At that point, I would prefer to add a column in YTD table called forecast and paste the Forecast data in it.
I tried that too by doing that but again it add all the total impression forecasted as a total...
Imp_Served = SUM(Forecast[Forecasted impressions])
- Greg_Deckler10 years agoCommunity Champion
It actually does make absolutely 100% sense if you understand that DAX and Power BI are all about context. As I explained above, you need a common context filter, otherwise the aggregation is going to get absolutely everything in the other table and just SUM it, etc. You could also relate your Date in Forecast to your Date in Impressions and then use the Date from Impressions as that provides the same, common context for calculations.
- elatreille10 years agoHelper I
Oh sorry, I am not saying that DAX makes no sense but the way I pull my reports, having to always add dates in a table just for that is a huge pain but I understand what you are saying and yes it does make sense.
I will try to do a related between these two and will let you know ;) thanks for your support
- Greg_Deckler10 years agoCommunity Champion
Generally, I just create a separate query to whatever my same data source is and just pull in the dates, remove duplicates and presto, a date table, or use DateStream in the Azure Marketplace. I think there is a way to do it automagically with CALCULATETABLE but I would have to confirm that.
- Greg_Deckler10 years agoCommunity Champion
- Sean10 years agoCommunity Champion
having a calendar table makes your life much easier (because you get to use the time intelligence functions)
you can do those calculations without it but you'll have to write a bit more
look here at this link provided by Matt
http://www.powerpivotpro.com/2015/02/create-a-custom-calendar-in-power-query/
- Sean10 years agoCommunity Champion
elatreille did you see you can copy and paste the code in the Query Editor - read how it works later
You can set set your first date here... so the calendar starts from that date - just make sure it is the earliest in your data set