Forum Discussion

Parvez933's avatar
Parvez933
Helper I
4 years ago

sumx()

Hi,

 

RetailerInvoice =
VAR bucket_min = CALCULATE(MIN('PCT-voice'[min]))
VAR bucket_max = CALCULATE(MAX('PCT-voice'[max]))
VAR total_printers = CALCULATE(DISTINCTCOUNT(Reatil[uniquekey])) return
SUMX(RetatilerMapping, VAR pct = [% Reatil] return
if(and(NOT ISBLANK(pct), and(pct > bucket_min, pct <= bucket_max)), 1)) / total_printers
 
Request your help in understanding how this DAX works, were
 
VAR bucket_min = CALCULATE(MIN('PCT-voice'[min])) ====> 0.00
 
VAR bucket_max = CALCULATE(MAX('PCT-voice'[max])) ====> 0.00
 
VAR total_printers = CALCULATE(DISTINCTCOUNT(Reatil[uniquekey])) ====> 22915
 
% Reatil ===> 1.50%
 
The result of "RetailerInvoice" is 82.15% or ~ 82%
 
I am unable to understand, how this 82% is coming based on what logic or how the last sumx() is functioning.
 
Please help

8 Replies

  • Parvez933 , as you have used at table name:  RetatilerMapping

    This one running for each row of the table

    Check like that


    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

  • OliT's avatar
    OliT
    Resolver I

    Hi Parvez933 

    This code is written incorrectly, thus getting the wrong result

    Can you share some data, and your expected results?


    Regards,

    OliT

    • OliT's avatar
      OliT
      Resolver I

      Hi Parvez933 

      It is not possible to infer what kind of results you need to calculate only by the wrong measure above, so I need some sample data and your expected result to write the measure, you can share some screenshots or share data in text format here. 

      Besides, the syntax for sumx is  SUMX(<table>, <expression>).

      Usually we can write it like this, sumx(filter(table,table[column]<max&&table[column]>min),<expression>)

       

      Regards,

      OliT

      • Parvez933's avatar
        Parvez933
        Helper I

        Hi Microsoft PowerBI Team,

         

        I have been awaiting your help in resolving the attachments issue, the topic is unresolved and experts are asking me to share some sample data which I am unable to share via any form of document.

         

        Request your help in sharing the attachments and resolve this topic asap.

  • I understand but, I am trying my best to share the sample which is not loading.

     

    I am unsure about the wrong measure, as because this is being used and created long ago, which I am trying to undestand

  • Hi Power BI Support Team,

     

    I need to Thank amitchandakOliT who are trying to help here.

     

    But as you see we are discussing to add some sample data here to progress which I am unable to.

     

    Request your help in sharing the contex via an pbix or txt or excel or word or any other file which can help others to understand and resolve this topic.