Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
awitt
Helper III
Helper III

Column calculation based on text string

Needing to create a calculated column that takes into account several other columns as well. A sample of my data is below.

 

image.png

Basically I need to take the revenue for the rows with an item version of "S" and evenly distribute that total revenue across non "s" items of the same order number and factor in quantity as well. For order 10001, there is $10 of "s" revnue and it would need to be broken up in $2.00 increments for the 5 total items that were sold. 

 

For Order 10002, there is $12.00 of "s" revenue that gets distributed amongs the 4 other total items. 

 

The "s" quantity is always 1. 

 

Thanks

1 ACCEPTED SOLUTION

HI, @awitt 

You could use this formula as below:

Column = 
IF (
    Sheet2[Item Version] <> "S",
    CALCULATE (
        SUM ( Sheet2[Per Item Revenue] ),
        FILTER (
            Sheet2,
            Sheet2[Order #] = EARLIER ( Sheet2[Order #] )
                && Sheet2[Item Version] = "S"
        )
    )
        / CALCULATE (
            SUM ( Sheet2[Quantity] ),
            FILTER (
                Sheet2,
                Sheet2[Order #] = EARLIER ( Sheet2[Order #] )
                    && Sheet2[Item Version] <> "S"
            )
        )
)

Result:

13.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
judspud
Solution Supplier
Solution Supplier

Hi @awitt 

 

you can use the all function inside a calculate function to do just this.

 

The process would be as follows;

 

Calculate(average, filter(all(TABLE),item version=itemversion))

 

EDIT: If it is possible to share a copy of your pbix file i would be happy to try and assist in creating such calculation.

 

Hope this helps

 

Thanks,

George

That just resulted in averaging the revnue without considering the order # or the quantity at all. Again the goal is to average out only the "S" revenue per order # amoungst all of the non "S" items.

 

Capture.PNG

HI, @awitt 

You could use this formula as below:

Column = 
IF (
    Sheet2[Item Version] <> "S",
    CALCULATE (
        SUM ( Sheet2[Per Item Revenue] ),
        FILTER (
            Sheet2,
            Sheet2[Order #] = EARLIER ( Sheet2[Order #] )
                && Sheet2[Item Version] = "S"
        )
    )
        / CALCULATE (
            SUM ( Sheet2[Quantity] ),
            FILTER (
                Sheet2,
                Sheet2[Order #] = EARLIER ( Sheet2[Order #] )
                    && Sheet2[Item Version] <> "S"
            )
        )
)

Result:

13.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors