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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
KasperJ90
Helper III
Helper III

Calculated column from table with multiple ranges

Hi,

 

Need your help to add a calculated column based on each category. I have table 1 showing my categories and ranges and then table 2 with the "operation number" to use to sum all minutes within the category range.

 

Table 1:

Category 1: 8000..8099|8200..8999 

Category 2: 2000..7999|9000..9999

 

Table 2:

Operation No.Minutes
85005
899910
250080
9999100

 

Calculated column for category 1 = sum all minutes within category 1 ranges (in this case 15)

Calculated column for category 2 = sum all minutes within category 2 ranges (in this case 180)

 

Thank you in advance!

1 ACCEPTED SOLUTION
OzkanDhont
Resolver II
Resolver II

Hi @KasperJ90 !

 

Do you need it to be a calculated column?

I've created something similar in the past but as a measure which will save up on your data model.

 

Measure = 
CALCULATE(
    SUM('Table (2)'[No.Minutes]),
    FILTER(
        'Table (2)',
            COUNTROWS(
                FILTER(
                    'Table (1)',
                    'Table (2)'[Operations] > 'Table (1)'[Min] &&
                    'Table (2)'[Operations] <= 'Table (1)'[Max]
                )
            )
         )
)

You can download the pbix file for better understanding: 

https://filetransfer.io/data-package/ltw0G1YS#link

 

Hope it helped!

 

Kind regards,

OD

View solution in original post

1 REPLY 1
OzkanDhont
Resolver II
Resolver II

Hi @KasperJ90 !

 

Do you need it to be a calculated column?

I've created something similar in the past but as a measure which will save up on your data model.

 

Measure = 
CALCULATE(
    SUM('Table (2)'[No.Minutes]),
    FILTER(
        'Table (2)',
            COUNTROWS(
                FILTER(
                    'Table (1)',
                    'Table (2)'[Operations] > 'Table (1)'[Min] &&
                    'Table (2)'[Operations] <= 'Table (1)'[Max]
                )
            )
         )
)

You can download the pbix file for better understanding: 

https://filetransfer.io/data-package/ltw0G1YS#link

 

Hope it helped!

 

Kind regards,

OD

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.