I'm trying to do something that in PowerApps that I can do quite simply in Excel, but as I keep trying, it seems it gets more and more complex.
I have 6 different date fields that I need to use to sort my gallery. These dates are stored in Excel with the entire columns formated as a Date "*3/14/1999". The names of these fields are: 'BLS', 'ACLS', 'MDL', 'ProvExp', 'PrivExp', 'taskFU-Date'
- I also need it to ignore some of these based off of whether the T/F value in 'tBLS', 'tMDL', and 'tPriv' field values are "True" or "False".
- I need to have it compare these dates in a very nested format as well.
- I created 3 labels where any True value returns the 'taskFU-Date' - the false values return as noted below:
In the first label, if it's False, then it will find the newest date between 'BLS' and 'ACLS'
DateValue(If(ThisItem.tBLS="True","",If(ThisItem.ACLS>ThisItem.BLS,ThisItem.ACLS,ThisItem.BLS)))
In the second label, if it's false, then pass on the 'MDL' date.
DateValue(If(ThisItem.tMDL="True","",ThisItem.'MDL'))
3rd Label: If it's false, then find the oldest date between PrivExp and ProvExp.
Text(If(ThisItem.tPriv="True",ThisItem.'taskFU-Date',If(ThisItem.pExp>ThisItem.pProvExp,ThisItem.pProvExp,ThisItem.pExp)),ShortDate)
Now I'd like to create a 4th label that finds the oldest date from all of these but I can't get it to work
- using If() statements (it says it expects # values)
- I try with DateDiff() but it expects date values and I've tried forcing it to render as a date value via
- Text(variable,ShortDate)
- DateValue()
- DateTimeValue()
- Value()
- Whatever I do, it's not a compatible format.
Am I overthinking it or am I not using the right tools for this?
My hope is to use the final date produced from this to sort my gallery.
---------------------------- Additional info requested by TheMexican
Okay, here is some stripped down data.
| ID | MDL | BLS | ACLS | PrivExp | ProvExp | taskFU-Date | tBLS | tPriv | tMDL | rBLS | rPriv | rMDL | rFinalSortDate |
| 64 | 6/30/2019 | 12/1/2018 | 5/1/2019 | 4/6/2018 | | 5/1/2018 | FALSE | TRUE | FALSE | 5/1/2019 | 5/1/2018 | 6/30/2019 | 5/1/2018 |
| 70 | 5/31/2018 | 7/1/2019 | | 6/21/2018 | | 5/1/2018 | FALSE | TRUE | FALSE | 7/1/2019 | 5/1/2018 | 5/31/2018 | 5/1/2018 |
| 17 | 12/31/2019 | 2/1/2016 | | 6/21/2018 | | 5/1/2018 | FALSE | TRUE | FALSE | 2/1/2016 | 5/1/2018 | 12/31/2019 | 2/1/2016 |
| 71 | 9/30/2019 | 3/1/2018 | | 10/11/2018 | | 4/19/2018 | TRUE | FALSE | FALSE | 4/19/2018 | 10/11/2018 | 9/30/2019 | 4/19/2018 |
| 54 | 5/31/2020 | 9/1/2019 | | 10/11/2018 | | | FALSE | FALSE | FALSE | 9/1/2019 | 10/11/2018 | 5/31/2020 | 10/11/2018 |
| 40 | 12/31/2019 | 11/1/2018 | | 12/7/2018 | | | FALSE | FALSE | FALSE | 11/1/2018 | 12/7/2018 | 12/31/2019 | 11/1/2018 |
| 14 | 9/30/2018 | 4/1/2019 | | 1/19/2019 | 5/28/2018 | 4/28/2018 | FALSE | TRUE | FALSE | 4/1/2019 | 4/28/2018 | 9/30/2018 | 4/28/2018 |
| 32 | 11/30/2017 | 5/31/2019 | | 11/28/2019 | | | FALSE | FALSE | FALSE | 5/31/2019 | 11/28/2019 | 11/30/2017 | 11/30/2017 |
| 28 | 4/30/2019 | 5/1/2019 | | 1/19/2019 | 7/24/2018 | 6/24/2018 | FALSE | TRUE | FALSE | 5/1/2019 | 6/24/2018 | 4/30/2019 | 6/24/2018 |
| 57 | 4/30/2020 | 12/1/2018 | 12/1/2018 | 1/19/2019 | | | FALSE | FALSE | FALSE | 12/1/2018 | 1/19/2019 | 4/30/2020 | 12/1/2018 |
| 59 | 4/30/2020 | 11/1/2019 | | 3/16/2019 | | | FALSE | FALSE | FALSE | 11/1/2019 | 3/16/2019 | 4/30/2020 | 3/16/2019 |
| 58 | 5/31/2018 | 9/1/2018 | | 5/5/2019 | | | FALSE | FALSE | FALSE | 9/1/2018 | 5/5/2019 | 5/31/2018 | 5/31/2018 |
| 74 | 7/31/2018 | 2/1/2018 | | 5/5/2019 | | 4/19/2018 | TRUE | FALSE | FALSE | 4/19/2018 | 5/5/2019 | 7/31/2018 | 4/19/2018 |
| 72 | 7/31/2018 | 7/1/2018 | | 5/5/2019 | | 7/1/2018 | TRUE | FALSE | FALSE | 7/1/2018 | 5/5/2019 | 7/31/2018 | 7/1/2018 |
| 39 | 3/31/2019 | 11/1/2019 | | 9/27/2019 | | | FALSE | FALSE | FALSE | 11/1/2019 | 9/27/2019 | 3/31/2019 | 3/31/2019 |
| 56 | 9/30/2019 | 8/1/2018 | | 5/5/2019 | | | FALSE | FALSE | FALSE | 8/1/2018 | 5/5/2019 | 9/30/2019 | 8/1/2018 |
| 75 | 5/31/2019 | 4/1/2018 | | 5/9/2019 | | 4/19/2018 | TRUE | FALSE | FALSE | 4/19/2018 | 5/9/2019 | 5/31/2019 | 4/19/2018 |
For the purposes of visualizing this data here in my post, I put the dates that match the last column in red.
The last FOUR columns are the formula columns I was using in excel (but for the purposes of PowerApps, I had to remove them because my app wouldn't read the table if it had formulas in any fields). The formulas for the last 4 columns were:
- 'rBLS' =IF([@tBLS]=TRUE,[@[taskFU-Date]],MAX([@BLS],[@ACLS]))
- 'rPriv' =IF([@tPriv]=TRUE,[@[taskFU-Date]],MIN([@PrivExp],[@ProvExp]))
- 'MDL' =IF([@tMDL]=TRUE,[@[taskFU-Date]],[@MDL])
- 'rFinalSortDate' =MIN([@rBLS],[@rPriv],[@rMDL])
I then sorted my table by 'rFinalSortDate'.
Final Result: In PowerApps, I'd like to sort my Gallery by that final sort date (but I have to find a way to make all the calculations that I was doing with Excel Formulas).