Forum Discussion

Kmptrgeek's avatar
Kmptrgeek
Frequent Visitor
4 years ago
Solved

% Grand Total using barcode scanner

I have a report that is working great with the barcode scanner...but my calculation for % Grand Total doesn't work when the product is scanned, only when it is selected from a table or other visual on the page.  When scanned, it only calculates based off the products that have been scanned, not the entire dataset.   

 

Here is my calculation:

 

% Grand Total of Volume = DIVIDE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]) ,
 (CALCULATE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]),                               allselected(BAS_MDM_UNITED_CUSTOMER[CUSTOMER_ID]), ALL(BAS_MDM_UNITED_PRODUCT)) ))
  • I think I have solved my issue.  In the DAX I've written I am filtering by all selected customers and all products.  When I modified my DAX to be the following it looks like the calculations are working with the scanner.  

     

    % Grand Total of Volume = DIVIDE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]) ,
     (CALCULATE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]), ALL()) ))
     
    Now I just have to figure out why my RANKX code isn't working with the scanner.  🙂

5 Replies

  • Hi Kmptrgeek ,

     

    Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

    Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

     

    Refer to:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,

    Jianbo Li

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

    • Kmptrgeek's avatar
      Kmptrgeek
      Frequent Visitor

      I have a report that has product information on it (first order date, number of orders, etc.) and one of the metrics is percent of grand total.  All of these metrics works correctly when the product is selected from a list of products (or filter)...but when a product is scanned using the barcode scanning capability, the percent of grand total calculation only uses the scanned product, not the entire dataset.  

       

      Does that make more sense?

       

  • Hi Kmptrgeek ,

     

    When you scanned, the visuals will be filtered by the product barcode you scanned.

    What is the % Grand Total calculated and does it vary depending on the item scanned? Or it is a fixed value?

    You can try to use some filter functions like REMOVEFILTERS() to remove the Barcode's filter.

    If that does not work, please provide me with more details about your table and the relationships between your tables or share me with your pbix file after removing sensitive data.

     

    Here are some Documnents, please check if these could help you a little:

    Filter functions (DAX) - DAX | Microsoft Docs

    REMOVEFILTERS function (DAX) - DAX | Microsoft Docs

     

    Refer to:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,

    Jianbo Li

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

    • Kmptrgeek's avatar
      Kmptrgeek
      Frequent Visitor

      The REMOVEFILTERS command will not work in my case because I'm am accessing the tables via Direct Connection.  I understand how the barcode scanning functionality works as far as filtering the visuals, I just don't understand how to write the DAX to get it to apply my calculation to the entire dataset instead of just what was scanned.  This DAX works when I filter to a specific product:

       

      % Grand Total of Volume = DIVIDE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]) ,
       (CALCULATE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]),                               allselected(BAS_MDM_UNITED_CUSTOMER[CUSTOMER_ID]), ALL(BAS_MDM_UNITED_PRODUCT)) ))
       
      My pbix file is massive and will take forever to remove the sensitive data.  This "seems" pretty straightforward to me as far as what the issue is.  It has nothing to do with the table schemas or anything like that...it's the DAX.  Why is it working with the filters in the report but not with the barcode scanner?
       
      Thank you for any assistance.
  • Kmptrgeek's avatar
    Kmptrgeek
    Frequent Visitor

    I think I have solved my issue.  In the DAX I've written I am filtering by all selected customers and all products.  When I modified my DAX to be the following it looks like the calculations are working with the scanner.  

     

    % Grand Total of Volume = DIVIDE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]) ,
     (CALCULATE(SUM(SUB_SETTLED_SALES[VV998_Q_PHYSICAL_CASES]), ALL()) ))
     
    Now I just have to figure out why my RANKX code isn't working with the scanner.  🙂