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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Bobass75
Frequent Visitor

How to fix range measure calculation

The goal for the measure is to calculate sales value ranges based on OPA_ID in the current context.

Range < 150k Sales Invoices Amount =

VAR FilteredOPA =

    FILTER (

               ADDCOLUMNS (

                SUMMARIZE ( 'Fact Sales Invoices', 'Dimension Opportunity Attributes'[OPA ID] ),

                "Sales", 'Fact Sales Invoices'[Sales Invoices Amount NOK]                      

            )

        ,

        [Sales] < 150000

    )

VAR selected =

    SELECTCOLUMNS ( FilteredOPA, 'Dimension Opportunity Attributes'[OPA ID] )

 

VAR Table_with_lineage =

    TREATAS ( selected, 'Dimension Opportunity Attributes'[OPA ID] )

 

RETURN

    CALCULATE ( 'Fact Sales Invoices'[Sales Invoices Amount], Table_with_lineage )

The problem is that the measure calculates incorrect values in rows if the context is on a product (ITM_ID)- an example below.



               measure <150kmeasure >=150-500kmeasure >=500k<1000k
OPA_ID 1146  
ITM1100  
ITM246  
OPA_ID 2  550
ITM360  
ITM480  
ITM5 270 
ITM6140  

How can I modify the measure so that the ITM3-ITM6 values appear in the third column, where sum is 550 (sum of OPA=550)?

 

Thank you in advance for your help.

3 REPLIES 3
Bobass75
Frequent Visitor

Thanks - it will be better if I attach an example 😁 - so 
Measures calculate correctly only OPA levels summary - I want  to have also correct ITM level summary (and Totals) based on OPA like  :

Bobass75_0-1753453984176.png
Thanks a lot !!

https://drive.google.com/file/d/1hLcXEbaiyvjvBw_tajke4uschQUNVQz0/view?usp=sharing 

 

V-yubandi-msft
Community Support
Community Support

Hi @Bobass75 ,

I’ve replicated your requirement using sample data and made some adjustments to the original measure to ensure it functions correctly.

FYI:

Vyubandimsft_0-1753418130319.png

Vyubandimsft_1-1753418147712.png

 

Vyubandimsft_2-1753418171172.png

 

 

I’ve attached the .pbix file for your review. Please let me know if it meets your needs or if you’d like any changes.

 

 

Best regards,

Yugandhar,

FBergamaschi
Solution Sage
Solution Sage

Hoping to have understood what yo uare willing to get

 

Range < 150k Sales Invoices Amount =

VAR FilteredOPA =

    FILTER (

               ADDCOLUMNS (

                SUMMARIZE ( 'Fact Sales Invoices', 'Dimension Opportunity Attributes'[OPA ID] ),

                "Sales", 'Fact Sales Invoices'[Sales Invoices Amount NOK]                      

            )

        ,

        [Sales] < 150000

    )

VAR selected =

    SELECTCOLUMNS ( FilteredOPA, 'Dimension Opportunity Attributes'[OPA ID] )

 

VAR Table_with_lineage =

    TREATAS ( selected, 'Dimension Opportunity Attributes'[OPA ID] )

 

RETURN

    CALCULATE ( 'Fact Sales Invoices'[Sales Invoices Amount], Table_with_lineage, REMOVEFILTERS ( Product[ProductNo] )

 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.