
Hello,
I am new to PowerApps, I have a scenario where I would like to filter a Column Chart based off a selected date range.
The Column Chart will show 2 series, one for "Earned" hours(Int) and another for "Labor" hours(Int). The label is the "Build Day"(Date String).
I Decided to incrementally increase the complexity of the filter of the item for the chart. I started with a basic 2 series chart with the label as the build day, and sorted the data based off the column used for the label.
SortByColumns(LaborEarnedHrs, "BuildDay")
Result - This is what I expected, all data points from the data source(SQL) sorted by Build Day. - Neat.
I then decided to see what would happen if I returned a single result based off a date picker, and used the following code on the chart item.
Filter(LaborEarnedHrs, BuildDay = DatePicker2.SelectedDate)
This resulted in no errors or warning but also no data, I even added a data table to verify my filters.
I assumed at this point that it was running into an issue with the date strings not matching in some way and used DateValue to help with that, however the data table shows the correct result, but the chart seems to not align the data point correctly on the x axis.
SortByColumns(Filter(LaborEarnedHrs, DateValue(BuildDay) = FromDate.SelectedDate), "BuildDay")
The ultimate goal here is to allow a user to select a date range and for it to sort and show the filtered data points on a column chart to easily visualize misses in the factories Earned Hours vs Planned Labor Hours. The following item code snippet, with 2 date pickers returns the correct result in a data table. However, the chart just stacks the results to the left.
SortByColumns(Filter(LaborEarnedHrs, DateValue(BuildDay) >= FromDate.SelectedDate && DateValue(BuildDay) <= ToDate.SelectedDate), "BuildDay")
Any help would be appreciated!
This issue was resolved. To anyone wondering why this was happening, the clearest way to explain it is, the data source contained Null Values for Earned Hours on Days where work was not completed, the null values themselves were causing the chart to stack the data to the left. The way we fixed this was to use the CASE argument in SQL to set the Earned Hours value to 0 in the case that they were null.