Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
joshuahirsch
Partner - Contributor III
Partner - Contributor III

How to get the last input from one day and afterwards make this Join?

Hey there,

I have a question:

Imagine Salepartners are adding Forecasts for a certain Quarter in a Year.

Now I only want ONE Forecast per YearQuarter per day from a Salespartner (the last one, so something with Max(ForecastId? I don't know, help please)

But I also want to create redundant data in the new table, to see, if a salespartner didn't post a forecast on a certain day, where others made a forecast.

I'll give you an example, I think it explains best.

I'm having this kind of Data:

Forecast IDSalespartner IDDate createdYearQuarter
12

01.01

19Q1
2201.0119Q1
3103.0119Q1
4203.0119Q2
5305.0119Q1
6103.0119Q2
7305.0119Q1

So, now I want to get a table like this:

Forecast IDSalespartner IDDate createdYearQuarter
--101.01--
31

03.01

19Q1
6103.0119Q2
--105.01--
2201.0119Q1
4203.0119Q2
--205.01--
--301.01--
--303.01--
7305.0119Q1

So if someone could help me with getting just one/last forecast of a day of a certain YearQuarter from a salespartner and creating this table with NULL values, i'd highly appreciate it!

Thanks a lot,

Josh

1 Reply
Thiago_Justen_

You could try this out:

Load
[Forecast ID],
LastValue ([Salespartner ID]) as [Salespartner ID],
LastValue ([Date created]) as [Date created],
LastValue (YearQuarter) as YearQuarter
From YourDB Group By [Forecast ID];
Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago