cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JeanFred
Frequent Visitor

Contextualization of a filter parameters

Hi all

 

I have been posting but it remain unsolved (I will link to this answer if anyone can find the way to proceed)

 

In a page I am struggling with creating a contextualization in the formulas of the entire page

My overall attempt : contextualize depending on the business name that appear on an item somewhere in the page 

 

Seems simple ? yes but so far I never found the right approach

 

The initial formula (that is working well 🙂 )

 

Text(
Sum(
Filter(
'PROJECTDB';
BUSINESS1>= 1);
(BHWQ1+BSWQ1+BINQ1+BEXQ1+BHWQ2+BSWQ2+BINQ2+BEXQ2+BHWQ3+BSWQ3+BINQ3+BEXQ3+BHWQ4+BSWQ4+BINQ4+BEXQ4)*BUSINESS1/100)
/1000;"[$-en-us]#,##")

 

So: I am creating an Item called BUSINESSNAME and for this page the value is BUSINESS1 and I am trying this formula 

 

Text(
Sum(
Filter(
'PROJECTDB';
Value(BUSINESSNAME.Text) >= 1);
(BHWQ1+BSWQ1+BINQ1+BEXQ1+BHWQ2+BSWQ2+BINQ2+BEXQ2+BHWQ3+BSWQ3+BINQ3+BEXQ3+BHWQ4+BSWQ4+BINQ4+BEXQ4)*Value(BUSINESSNAME.Text)/100)
/1000;"[$-en-us]#,##")

 

or this formula :

Text(
Sum(
Filter(
'PROJECTDB';
BUSINESSNAME.Text >= 1);
(BHWQ1+BSWQ1+BINQ1+BEXQ1+BHWQ2+BSWQ2+BINQ2+BEXQ2+BHWQ3+BSWQ3+BINQ3+BEXQ3+BHWQ4+BSWQ4+BINQ4+BEXQ4)*ValueBUSINESSNAME.Text/100)
/1000;"[$-en-us]#,##")

 

always the same results : no results (empty Item) Instead of properly proceeding the calculation - I know that the 1st way to proceed should work ! but it does not work (probably due to the other elements of the formula)

 

Any Idea? I am REALLY Struggling with it ! 😞

 

Many thanks

BR

Jean fred

1 ACCEPTED SOLUTION

Accepted Solutions
JeanFred
Frequent Visitor

o and Thank you @BCLS776 

 

I will review my DB : despite the advantage of having an easiest way to search for data is there any other avantages to have various small tables ? will it make the apps more rapid ? 

 

For my specific request For Any reason I discovered that when I am duplicating the screen business1 and rename the new scrren Business2 Power apps automatically adapt the content of each line of code with Business2 !!!! thas a Very good news answering my need ! 😉 

 

many thanks again

BR

Jean fred

View solution in original post

9 REPLIES 9
BCLS776
Super User
Super User

If I understand you correctly, the BUSINESSNAME.Text property in some cases contains a string such as: "BUSINESS1"? If that's the case, the Value() function will not evaluate a string such as "BUSINESS1". Value() can only operate on a string that looks like a number, e.g. "12.34".

 

Instead, try using an If() or Switch() to control the logic of your app:

 

Switch(BUSINESSNAME.Text,
    "BUSINESS1", /* Insert code for case 1 here */ ,
    "BUSINESS2", /* Insert code for case 2 here */ ,
    // and so on
    /* Insert code for default case as the last argument */
)

 

Hope this helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
JeanFred
Frequent Visitor

Thank you for the proposal @BCLS776 

Now I understand why the value() function does not work

Yes the idea is to have the text of business 

 

My intend is more to contextualize the page ... and in my code to have businessname as a variable

in your solution I do have to repeat the code plenty time ...for business 1 ...etc and as I do have a lot of figures to retrieve in the page not the simplest

 

Is there any other way to manage to have a variable ? I can also change the way I do build the page if needed 

Yes, you can use the Set() function for global variables, UpdateContext() for screen-scope variables, or even use a collection to temporarily store some values.

 

Perhaps the solution to your issue is to use a Switch() to set a variable to the value you need for a subsequent calculation?

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
JeanFred
Frequent Visitor

HI 

 

thank you @BCLS776 

So I have been trying the switch function as initially proposed and it lead to at least 8 pages of code / data (to heavy too long to code ... not what I need) 

 

SO I have been Trying your proposal of SET() (or actually I have been trying UpdateContext() as the Idea is to change depending on each page (one page for business1 , one for Business2...)

 

 

The update context is working well 

when i Try to integrate the variabe in the code the retunr is the same : blank field

 

I have been using this formula : maybe i did it wrong ? :

 

First I did a button (to update context)

UpdateContext({BusinessName:"Business1"})

 

Text(
Sum(
Filter(
'2022 DB';
BusinessName>= 1);
(BHWQ1+BSWQ1+BINQ1+BEXQ1+BHWQ2+BSWQ2+BINQ2+BEXQ2+BHWQ3+BSWQ3+BINQ3+BEXQ3+BHWQ4+BSWQ4+BINQ4+BEXQ4)*BusinessName/100)
/1000;"[$-en-us]#,##")

 

 

any Idea? I did smthg wrong?

 

many thx

BR

JeanFred

Hi @JeanFred,

 

Yes, there is an issue with your code. The statement: UpdateContext({BusinessName:"Business1"}) sets the value of the variable BusinessName to a string that contains "Business1". Then your subsequent filter and calculation attempt to compare this string to a numerical value and perform a mathematical operation on it:

 

Text(
Sum(
Filter(
'2022 DB';
BusinessName>= 1);
(BHWQ1+BSWQ1+BINQ1+BEXQ1+BHWQ2+BSWQ2+BINQ2+BEXQ2+BHWQ3+BSWQ3+BINQ3+BEXQ3+BHWQ4+BSWQ4+BINQ4+BEXQ4)*BusinessName/100)
/1000;"[$-en-us]#,##")

 

 

I have marked in bold text where BusinessName is being handled as though it has a numerical value. In this Filter() you are asking Power Apps to evaluate "Business1" >= 1, which doesn't work so the Filter() returns no records.

 

Is BusinessName supposed to be a numerical value in your app, or do you need to substitute something else there whenever BusinessName equals a particular string (e.g. "Business1")?

 

Consider this example code:

If( // must go in an behavior field, such as OnSelect
    Label1.Text = "Business1", UpdateContext({ varBusiness: 0.5}),
    Label1.Text = "Business2", UpdateContext({ varBusiness: 1.5}),
    Label1.Text = "Business3", UpdateContext({ varBusiness: 2.0}),
    UpdateContext({ varBusiness: 3.0})
)
// This statement sets varBusiness to different values depending on the contents of Label1.Text

varBusiness in this example always gets a numerical value, so it can be compared to other numerical values or used in a mathematical expression. Is that more like what you are trying to do?

 

Bryan

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
JeanFred
Frequent Visitor

Hi Bryan ! (@bcls776) 

First of all I d like to warmly thank you for the time you dediate to support me and this community - Very much appreciated

 

Actualy in my code, Business1 is the name of the column (as is business2 business 3...)

Each column mays have numerical values in it to split the spend between the different business (egs: Business1=20% Business2= 50% and Business3=30%) 

 

my attempt is

1-to create a page for each business 

2-to check in each column if is there any % indicated for this specific business

3-If yes then to sum columns and then to proratize depending on the value indicated in the column business

 

So in my example I would like to sum all the lines of the columns BHWQ1+BSWQ1+BINQ1+BEXQ1+BHWQ2+... if the column business1 >1% and then to divide it by the percent of business1 of each line

 

The thing is that it is working perfectly when I harcode Business1 instead of making it variable (I can hardcode it but it will take me ages to change the value of business1,2 etc in each pages

is it more clear ?  🙂 (sorry not that easy to explain)


@JeanFred wrote:

 

Actualy in my code, Business1 is the name of the column (as is business2 business 3...)

Each column mays have numerical values in it to split the spend between the different business (egs: Business1=20% Business2= 50% and Business3=30%) 

 

JeanFred, this changes things quite a bit - Power Apps does not support dynamically switching columns in an expression. In fact, your underlying data structure might be leading you to do things that will be difficult for you later on. It sounds like you are trying to store ALL your data in a single table, which leads to a massive, difficult-to-manage table later on. Strongly consider if you should be organizing your data into at least two tables: one with your main database, and a second that is used for looking up these percentages. The second table would have a column structure like this:

 

Table2

BusinessName

PortionName

PortionValue

 

And the rows would look something like:

BusinessNamePortionNamePortionValue
ABC CompanyBusiness10.20
ABC CompanyBusiness20.50
ABC CompanyBusiness30.30
XYZ CompanyBusiness10.50
XYZ CompanyBusiness20.50

 

With this table structure, you can use the LookUp() function to put out specific values to use in your calculation. For example, LookUp(Table2, BusinessName = "ABC Company" && PortionName = "Business2", PortionValue) returns a value of 0.5 that you can use in a calculation. You can substitute other values in your app for the search strings (e.g. Label1.Text for "ABC Company") to avoid hardcoding many cases. This is how you handle dynamic values in an app in a way that you can maintain/sustain in the future. Make sense?

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
JeanFred
Frequent Visitor

o and Thank you @BCLS776 

 

I will review my DB : despite the advantage of having an easiest way to search for data is there any other avantages to have various small tables ? will it make the apps more rapid ? 

 

For my specific request For Any reason I discovered that when I am duplicating the screen business1 and rename the new scrren Business2 Power apps automatically adapt the content of each line of code with Business2 !!!! thas a Very good news answering my need ! 😉 

 

many thanks again

BR

Jean fred


@JeanFred wrote:

 

I will review my DB : despite the advantage of having an easiest way to search for data is there any other avantages to have various small tables ? will it make the apps more rapid ? 

 

 


Smaller tables are naturally faster to process than very large tables. They are less prone to data limit problems, and they make it easier to add functionality to & maintain your app in the future. Finally, once you start structuring your data across multiple tables, you should see how intuitive the data structure becomes.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (810)