Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Get Grand Total Basis Conditions

Hi,

Insert TimeProduct 1Product 2LocationCategorySupplierQtyWeek DateConditionDuplication Check
          


I have the above Table

I need a DAX which calculates the Grand Total Basis conditions.

If Condition = 1 Then Calculate Grand Total Per Week
If Condition = 2 Then Calculate Grand Total Per Week


  • Hi Anonymous, a coupld of things

     

    1 - Can you please clarify the below? It seems the same thing is requested in both conditions

    If Condition = 1 Then Calculate Grand Total Per Week
    If Condition = 2 Then Calculate Grand Total Per Week

    2 - Please include, in a usable format, not an image, a small set of rows for each of the tables involved in your request and show the data model in a picture, so that we can import the tables in Power BI and reproduce the data model. The subset of rows you provide, even is just a subset of the original tables, must cover your issue or question completely. Alternatively, you can share your .pbix via some cloud service and paste the link here. Do not include sensitive information and do not include anything that is unrelated to the issue or question. Please show the expected outcome based on the sample data you provided and make sure, in case you show a Power BI visual, to clarify the columns used in the grouping sections of the visual.

     

    Need help uploading data? click here

     

    Want faster answers? click here

  • Hello Anonymous 

     

    If there’s exactly one condition in the current filter context, you can try the DAX logic below, 

    SWITCH(
        TRUE(),
        SELECTEDVALUE('Table'[Condition]) = 1,
            CALCULATE(
                SUM('Table'[Qty]),
                ALLEXCEPT('Table', 'Table'[Week Date])
            ),
        SELECTEDVALUE('Table'[Condition]) = 2,
            CALCULATE(
                SUM('Table'[Qty]),
                ALLEXCEPT('Table', 'Table'[Week Date])  //adjust if logic differs
            )
    )

    ALLEXCEPT('Table', 'Table'[Week Date]) forces totals at the week level, ignoring product, supplier, category, etc. 

5 Replies

  • Hi Anonymous, a coupld of things

     

    1 - Can you please clarify the below? It seems the same thing is requested in both conditions

    If Condition = 1 Then Calculate Grand Total Per Week
    If Condition = 2 Then Calculate Grand Total Per Week

    2 - Please include, in a usable format, not an image, a small set of rows for each of the tables involved in your request and show the data model in a picture, so that we can import the tables in Power BI and reproduce the data model. The subset of rows you provide, even is just a subset of the original tables, must cover your issue or question completely. Alternatively, you can share your .pbix via some cloud service and paste the link here. Do not include sensitive information and do not include anything that is unrelated to the issue or question. Please show the expected outcome based on the sample data you provided and make sure, in case you show a Power BI visual, to clarify the columns used in the grouping sections of the visual.

     

    Need help uploading data? click here

     

    Want faster answers? click here

  • Hello Anonymous 

     

    If there’s exactly one condition in the current filter context, you can try the DAX logic below, 

    SWITCH(
        TRUE(),
        SELECTEDVALUE('Table'[Condition]) = 1,
            CALCULATE(
                SUM('Table'[Qty]),
                ALLEXCEPT('Table', 'Table'[Week Date])
            ),
        SELECTEDVALUE('Table'[Condition]) = 2,
            CALCULATE(
                SUM('Table'[Qty]),
                ALLEXCEPT('Table', 'Table'[Week Date])  //adjust if logic differs
            )
    )

    ALLEXCEPT('Table', 'Table'[Week Date]) forces totals at the week level, ignoring product, supplier, category, etc. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous 
      MasonMA FBergamaschi Thanks for the inputs.

      I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

        I wanted to check if you had the opportunity to review the information provided by users. Please feel free to contact us if you have any further questions.