Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi community,
Need some help with an expression for a bar chart. Attached is a spreadsheet with sample data for you to refer to.
Essentially, for every [Start Date] I need to calcuate:
Sum({$<[ContractsFull.ContractPeriod]={'Future'}>} [ContractsFull.ContractedFTE])
But as you can see there are multiple results per [Start Date]. So I only want the calculation to include data in the row of latest ContractsFull.SnapshotDate per [Start Date].
I tried using FirstSortedValue within an Aggr() expression but can't get it to work properly... Any ideas?
Note: [Start Date] actually comes from another table of data that joins by the ContractsFull.SnapshotDate, like a master calendar.
Thanks
Carl
hi,
DIM: Start date
Expression of bar chart:
(Sum({$<ContractsFull.ContractPeriod = {"Future"}>} ContractsFull.ContractedFTE))
your bar chart will be show below result in chart.
ksrini
Hi Ksrinivasan,
Thanks but see how it is suming the values for all SnapshotDates that relate to that start date?
I need it to just sum the last value from within each Start Date range. Can't use distinct because in the full data set, there are 1,000s of employees included. The ContractID column identifies an individual, so I need to include something like FirstSortedValue and grouping it by the ContractID...
So it should come out as:
Any ideas?
Hi @blunckc1
You should attach a better data sample, the current one only contains the ContractID 0017626332012900, then We don't have enough data to help you.
Hi @ArnadoSandoval,
More data attached 🙂 the pivot table shows the expected result in the bar chart.
I know I can achieve this by making changes to how I load the data, but want to see if that can be avoided...
Cheers
Carl
Hi @blunckc1
Thanks for the new sample of data and the pivot table you included, it helped me to reconcile the results, first let me explain my steps (I attached the solution as well).
Aggr(Sum({<"[Start Date]"={'8/3/2021'},ContractsFull.ContractPeriod={'Future'}>} [ContractsFull.ContractedFTE]), [ContractsFull.SnapshotDate])
Aggr(Sum({<"[Start Date]"=,ContractsFull.ContractPeriod={'Future'}>} [ContractsFull.ContractedFTE]), [ContractsFull.SnapshotDate])
Aggr(Count({<"[Start Date]"=,ContractsFull.ContractPeriod={'Future'}>} [ContractsFull.ContractID]), [ContractsFull.SnapshotDate])
Hope this helps,
Hi @blunckc1
This is the screenshot showing the results from the attached application.
Hi @ArnadoSandoval ,
Thanks so much for this work. Weirdly, I get "-" when using this expression:
Aggr(Sum({<"[Start Date]"=,ContractsFull.ContractPeriod={'Future'}>} [ContractsFull.ContractedFTE]), [ContractsFull.SnapshotDate])
The data model is slightly different though, will this cause it?
If you change your load script to this your data model will match mine (basically).
Contracts:
LOAD
ContractsFull.ContractID,
ContractsFull.SnapshotDate,
ContractsFull.ContractedFTE,
ContractsFull.ContractPeriod
FROM [lib://Sample_Data/SampleData-FirstSortedValue.xlsx]
(ooxml, embedded labels, table is Sheet1);
PayPeriods:
Load
ContractsFull.SnapshotDate,
"[Start Date]"
FROM [lib://Sample_Data/SampleData-FirstSortedValue.xlsx]
(ooxml, embedded labels, table is Sheet1);
hi,
only condition you have to select Future from filter or create bookmark as Default "Future"
ksrininvasan
hi,
ksrinivasan