cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
n8greene
Level: Powered On

If statement will not work in Items property of Chart Control

Hi-

I have several collections feeding several small charts on single screen. This part is working fine. (pictured below)

ThumbnailGraphs.PNG

These charts are fed by the following collections, respectively, in their Items property: colMonthlyRevenue, colMontlyExpenses, colMonthlywRVU, colMonthlyVisits

Each chart title is a link that opens a seperate screen, screenLineDetail, to show the chart you clicked on but BIGGER using this formula:

Set(varDetailChartTitle,"Revenue");Navigate(screenLineDetail,ScreenTransition.Cover)

 

 

The items property of the big chart looks like this. The idea is to have one chart but display a different collection based on what link was pressed on the previous screen. But it doesn't work. 

 

If(
varDetailChartTitle="Expenses",colMonthlyExpenses,
varDetailChartTitle="Revenue",colMonthlyRevenue,
varDetailChartTitle="Visits",colMonthlyNet,
varDetailChartTitle="wRVU",colMonthlywRVU

)

 

If any of these collections are typed directly into the items property of the big table, they work fine. But if I put them in an if statement they fail.

This fails:

If(1=1,varMontlyExpenses, varMonthlyRevenue)

But this works:

If(1=1,varMontlyExpenses) and even this works: If(1=1,varMontlyExpenses, varMonthlyExpenses)

 

It's as though I can't have more than one collection named in the formula. 

 

Failure looks like this. It just shows one one datapoint (May). 

2018-07-24 14_08_46-IMG Variance - PowerApps.png

I also tried passing the collection to the big chart in a global variable but got the same results. 

1 ACCEPTED SOLUTION

Accepted Solutions
nickduxfield
Level 8

Re: If statement will not work in Items property of Chart Control

Build a single collection from

"Expenses"
Revenue"
Visits",colMonthlyNet,
"wRVU"

 

Call it FilterCollection

Based on assumptions, I can deduce from the charts that you have similar or identical fields in which to populate the charts.

Therefore create a compatible collection using interchangable columns.

 

ClearCollect(FilterCollection,

{

Category:0,

Title:"",

XValue:0

YValue:0,

}

);

Concurrent(

Collect(FilterCollection,

ForAll(colMonthlyRevenue, Collect(FilterCollection,

{

Category:1, // Revenue

Title:"Revenue",

XValue: SomeValue

YValue: SomeValue

}

)),

Collect(FilterCollection,

ForAll(colMonthlyExpenses, Collect(FilterCollection,

{

Category:1, // Expenses

Title:"Expenses",

XValue: SomeValue

YValue: SomeValue

}

)),

Collect(FilterCollection,

ForAll(colMonthlyNet, Collect(FilterCollection,

{

Category:1, // MonthlyNet

Title:"MonthlyNet",

XValue: SomeValue

YValue: SomeValue

}

)),

Collect(FilterCollection,

ForAll(colMonthlywRVU, Collect(FilterCollection,

{

Category:1, // WRVU

Title:"WRVU",

XValue: SomeValue

YValue: SomeValue

}

))

)

 

Then place on the TitleURL property with a similar pattern using another TempCollection to store values, or a contextvariable.

For this example, I can demonstrate with a context variable:

Navigate(Screen,Transition,{varCategory:x}) //where x is the category value you assigned in the FilterCollection build.

 

Then in the single chart items property

Filter(FilterCollection, Category=varCategory)

 

Reasoning:

  1. You can place a single collection in the items property of the chart.
  2. The columns donot change
  3. The collection is merely filtered.

Ill look into it further on my end, open to questions

6 REPLIES 6
Lisabel0
Level 8

Re: If statement will not work in Items property of Chart Control

Can you share the data in these collections? Also the formulas that used to create them.

n8greene
Level: Powered On

Re: If statement will not work in Items property of Chart Control

For anyone who may stumble on this with a similar problem, I was never able to get one large table to accept different collections conditionally. This may be a bug and it may be fixed in the future, of course. For now, my plan is to just create muliple large charts--one for each collection and make them visible or hidden as needed. 

nickduxfield
Level 8

Re: If statement will not work in Items property of Chart Control

Have you tried a switch statement?

Have you tried to pump all the collections into 1 collection?

n8greene
Level: Powered On

Re: If statement will not work in Items property of Chart Control

Nick-

Good idea to try Switch. Unfortunately I get the exact same results as the If statement: As soon as I put more than one colection into the statement, it fails. 

 

Regarding your second suggestion about combining all collections into a single collection, I could certainly do that but I don't follow how this would help. Can you elaborate?

nickduxfield
Level 8

Re: If statement will not work in Items property of Chart Control

Build a single collection from

"Expenses"
Revenue"
Visits",colMonthlyNet,
"wRVU"

 

Call it FilterCollection

Based on assumptions, I can deduce from the charts that you have similar or identical fields in which to populate the charts.

Therefore create a compatible collection using interchangable columns.

 

ClearCollect(FilterCollection,

{

Category:0,

Title:"",

XValue:0

YValue:0,

}

);

Concurrent(

Collect(FilterCollection,

ForAll(colMonthlyRevenue, Collect(FilterCollection,

{

Category:1, // Revenue

Title:"Revenue",

XValue: SomeValue

YValue: SomeValue

}

)),

Collect(FilterCollection,

ForAll(colMonthlyExpenses, Collect(FilterCollection,

{

Category:1, // Expenses

Title:"Expenses",

XValue: SomeValue

YValue: SomeValue

}

)),

Collect(FilterCollection,

ForAll(colMonthlyNet, Collect(FilterCollection,

{

Category:1, // MonthlyNet

Title:"MonthlyNet",

XValue: SomeValue

YValue: SomeValue

}

)),

Collect(FilterCollection,

ForAll(colMonthlywRVU, Collect(FilterCollection,

{

Category:1, // WRVU

Title:"WRVU",

XValue: SomeValue

YValue: SomeValue

}

))

)

 

Then place on the TitleURL property with a similar pattern using another TempCollection to store values, or a contextvariable.

For this example, I can demonstrate with a context variable:

Navigate(Screen,Transition,{varCategory:x}) //where x is the category value you assigned in the FilterCollection build.

 

Then in the single chart items property

Filter(FilterCollection, Category=varCategory)

 

Reasoning:

  1. You can place a single collection in the items property of the chart.
  2. The columns donot change
  3. The collection is merely filtered.

Ill look into it further on my end, open to questions

n8greene
Level: Powered On

Re: If statement will not work in Items property of Chart Control

Nick-thanks for spelling this out so clearly. I think you’re right that this is the best appeoach under the circumstances. Thanks!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 212 members 3,574 guests
Please welcome our newest community members: