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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
navind
Regular Visitor

Calculation group with multiple facts

Hi Guys, 

We have below calculation group  code for single  fact which works fine, we are calling other measure which we create tocalaulate amount  along with cal item

Calculation item = CALCULATE(SELECTEDMEASURE(),FILTER('FACT_SUMMARY','FACT_SUMMARY'[ProductID] = "Grade1"))
 
Provide accurate results, we need to expand the code to other facts which has similar Product ID , As we tried below code if skews numbers
 Calculation item
 
VAR _IsProductID=
    CONTAINS('FACT_SUMMARY', 'FACT_SUMMARY'[ProductID], "Grade1")
    ||
 CONTAINS('FACT_SUMMARY', 'FACT_SUMMARY2'[ProductID], "Grade1")
    ||
  CONTAINS('FACT_SUMMARY', 'FACT_SUMMARY3'[ProductID], "Grade1")
RETURN
IF(
    _IsProductID,
    CALCULATE(
        SELECTEDMEASURE()
    )
)
 
Final Ouput  in matrix :
                              Amt from Fact 1         Amt from Fact 2                   Amt from Fact 2
      Grade 1                             20                                       5                                    5
 
Regards,
9
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @navind ,

It seems like you're trying to apply a calculation item across different fact tables, but you're encountering issues with skewed numbers.

 

Firstly, it's important to ensure that your calculation item logic correctly identifies the relevant Product IDs across all fact tables. The approach you've taken with the CONTAINS function should work in theory, but it's crucial to ensure that the relationships between your fact tables and the dimension table containing the Product IDs are correctly set up in your model. This ensures that the CONTAINS function can accurately filter the rows.

 

However, using CONTAINS in this manner might not be the most efficient way to filter for "Grade1" across multiple fact tables. Instead, consider leveraging the existing relationships in your model. If your fact tables are related to a common dimension table (e.g., a Product dimension table), you can simplify your calculation item by filtering on this dimension table directly, assuming that the ProductID "Grade1" is present in this dimension.

 

Here's a revised approach:

 

Calculation item =
CALCULATE(
    SELECTEDMEASURE(),
    FILTER(
        ALL('ProductDimension'), 
        'ProductDimension'[ProductID] = "Grade1"
    )
)

 

In this revised approach, replace 'ProductDimension' with the actual name of your Product dimension table that is related to your fact tables. This method assumes that there's a single, consistent Product dimension that all your fact tables relate to, which simplifies the filtering logic.

 

 

Best regards,
Community Support Team_Binbin Yu
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

1 REPLY 1
v-binbinyu-msft
Community Support
Community Support

Hi @navind ,

It seems like you're trying to apply a calculation item across different fact tables, but you're encountering issues with skewed numbers.

 

Firstly, it's important to ensure that your calculation item logic correctly identifies the relevant Product IDs across all fact tables. The approach you've taken with the CONTAINS function should work in theory, but it's crucial to ensure that the relationships between your fact tables and the dimension table containing the Product IDs are correctly set up in your model. This ensures that the CONTAINS function can accurately filter the rows.

 

However, using CONTAINS in this manner might not be the most efficient way to filter for "Grade1" across multiple fact tables. Instead, consider leveraging the existing relationships in your model. If your fact tables are related to a common dimension table (e.g., a Product dimension table), you can simplify your calculation item by filtering on this dimension table directly, assuming that the ProductID "Grade1" is present in this dimension.

 

Here's a revised approach:

 

Calculation item =
CALCULATE(
    SELECTEDMEASURE(),
    FILTER(
        ALL('ProductDimension'), 
        'ProductDimension'[ProductID] = "Grade1"
    )
)

 

In this revised approach, replace 'ProductDimension' with the actual name of your Product dimension table that is related to your fact tables. This method assumes that there's a single, consistent Product dimension that all your fact tables relate to, which simplifies the filtering logic.

 

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.