Reputation: 233
I am currently working on a project on PowerBI. I have a database named STATUS_PER_SCHEMA
which has a column named RUN_TIME
which tells when the batch was run. The database has values for RUN_TIME for each schema for the last 10 days. I want to use the same column twice in a single table. So basically I want the last and the first batch timing for each schema.
It should look something like this.
SCHEMA LAST_BATCH_RUN EARLIEST_BATCH_RUN
A 2018-05-21 12:00 2018-05-16 13:00
B 2018-05-21 12:00 2018-05-16 13:00
C 2018-05-21 12:00 2018-05-16 13:00
D 2018-05-21 12:00 2018-05-16 13:00
E 2018-05-21 12:00 2018-05-16 13:00
F 2018-05-21 12:00 2018-05-16 13:00
Upvotes: 0
Views: 2085
Reputation: 40204
You can stick the SCEHMA
column in a matrix visual Rows section and create one measure for last run and one measure for the earliest run and drop those measures in the Values section.
LAST_BATCH_RUN = MAX(RUN_TIME)
EARLIEST_BATCH_RUN = MIN(RUN_TIME)
Upvotes: 1
Reputation: 48810
How about:
select
SCHEMA,
max(RUN_TIME) as LAST_BATCH_RUN,
min(RUN_TIME) as EARLIEST_BATCH_RUN
from STATUS_PER_SCHEMA
group by SCHEMA
Upvotes: 0