Forum Discussion

kris_talikowski's avatar
kris_talikowski
Frequent Visitor
1 year ago
Solved

DAX measure Sum with nested filter condition 'or' 'and'

This nested and/or so simple in Excel in SQL drives me mad in Fabric. Please assist.
MeasureSales =
CALCULATE (
    SUM ( Sales[Sales Approved] ),
 
    ([MeasureSupplierUS]=1 && [MeasureTownsUS]=1) ||
    ([MeasureSupplierEU]=1 && [MeasureTownsEU]=1) ||
    ([MeasureSupplierXX]=1 && [MeasureTownsXX]=1)
    )
These below work
MeasureSuppliersUS = SUMX ( FILTER ( 'Suppliers', CONTAINSSTRING ( 'Suppliers'[Supplier Region], "US" ) ), 1 )
MeasureTownsUS = SUMX ( FILTER ( 'Towns', CONTAINSSTRING ( 'Towns'[Town Region], "US" ) ), 1 )
  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for the reply from Ashish_Mathur , please allow me to provide another insight:

    Hi, kris_talikowski 

    Firstly, I should mention that if your issue indeed involves recursion, I regret to inform you that DAX currently cannot fully address recursive problems. Therefore, I would recommend using Excel to resolve the issue.

     

    Secondly, based on the data you provided, I suggest converting your DAX operations into Power Query actions:

     

    1.Here is my sample data:

    2.Next, I perform a split operation on the Town table and the Suppliers table:

    3.Additionally, I carry out an Unpivot operation:

    4.Then, I perform a merge query operation:

    5.This will allow you to obtain a table of regions that exist in both tables.

    6.Finally, establish a relationship between the Sales table and the merged table:

    Below are my final results, which I hope meet your needs:

    Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

     

    For questions about uploading data, you can try the following links:

    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

    Solved: How to upload PBI in Community - Microsoft Fabric Community

     

    Please find the attached pbix relevant to the case.

     
    Of course, if you have any new ideas, you are welcome to contact us.
     

    Best Regards,

    Leroy Lu

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

     

2 Replies

  • Hi,

    Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from Ashish_Mathur , please allow me to provide another insight:

    Hi, kris_talikowski 

    Firstly, I should mention that if your issue indeed involves recursion, I regret to inform you that DAX currently cannot fully address recursive problems. Therefore, I would recommend using Excel to resolve the issue.

     

    Secondly, based on the data you provided, I suggest converting your DAX operations into Power Query actions:

     

    1.Here is my sample data:

    2.Next, I perform a split operation on the Town table and the Suppliers table:

    3.Additionally, I carry out an Unpivot operation:

    4.Then, I perform a merge query operation:

    5.This will allow you to obtain a table of regions that exist in both tables.

    6.Finally, establish a relationship between the Sales table and the merged table:

    Below are my final results, which I hope meet your needs:

    Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

     

    For questions about uploading data, you can try the following links:

    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

    Solved: How to upload PBI in Community - Microsoft Fabric Community

     

    Please find the attached pbix relevant to the case.

     
    Of course, if you have any new ideas, you are welcome to contact us.
     

    Best Regards,

    Leroy Lu

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