web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Calculation reference ...
Power Pages
Suggested Answer

Calculation reference from 1 field or another if empty

(0) ShareShare
ReportReport
Posted on by 6
Hi All,
 
I want to create a distinct colA and ColB, if ColA is empty need to display ColB and viceversa in Gallery 
 
ColA Col B
1 1
2 2
3 3
4  
  1
4  
Categories:
I have the same question (0)
  • Suggested answer
    Inogic Profile Picture
    1,291 Moderator on at
    Hi,
     
    To achieve a distinct display of ColA and ColB in a Power Apps Gallery where, if ColA is empty, it shows ColB and vice versa, you can follow these steps:

    Solution Steps:
    Prepare the Data Source: Ensure your data source has ColA and ColB fields as shown in your example.

    Add a Gallery Control: In Power Apps, add a Gallery control to your screen and connect it to your data source.

    Display Logic for Distinct Values: To create a distinct list where either ColA or ColB is shown based on availability, you can use the following formula in the Gallery’s Items property:

    powerfx
    Copy code
    ForAll(
        Distinct(
            Filter(
                YourDataSource,
                Not(IsBlank(ColA)) Or Not(IsBlank(ColB))
            ),
            If(
                IsBlank(ThisRecord.ColA),
                ThisRecord.ColB,
                ThisRecord.ColA
            )
        ),
        { DisplayValue: Result }
    )
    Explanation of the formula:
    Filter: Filters records to include only those where either ColA or ColB is not blank.
    Distinct: Ensures unique values in the list.
    If: Checks if ColA is blank. If so, it uses ColB; otherwise, it uses ColA.
    ForAll: Creates a record for each distinct value with a DisplayValue field, which you can use to display in the Gallery.
    Display the Result in the Gallery:

    Set a label within the Gallery to display ThisItem.DisplayValue.
    This will display the unique values from ColA and ColB in your Gallery based on your specified conditions.

    Hope this helps.
     
    Thanks!
    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Drop an email at crm@inogic.com 
    Service: https://www.inogic.com/services/ 
    Tips and Tricks: https://www.inogic.com/blog/ 
  • Suggested answer
    SaiRT14 Profile Picture
    1,992 Super User 2025 Season 1 on at
    • Use the AddColumns function with If(IsBlank(...)) to add a new column that checks for values in ColA and displays ColB if ColA is blank.
    • Set the Items property of the Gallery
    AddColumns(
        Distinct(MyCollection, ColA & ColB),
        "DisplayValue",
        If(
            !IsBlank(ColA), ColA,
            ColB
        )
    )
     
    • In the gallery, bind the Text property of a label control to ThisItem.DisplayValue to show either ColA or ColB based on availability.
    it should fix, let me know if  you need more details.
     
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 50

#2
Valantis Profile Picture

Valantis 26

#3
omkarsupreme Profile Picture

omkarsupreme 24

Last 30 days Overall leaderboard