Forum Discussion

mb0307's avatar
mb0307
Responsive Resident
6 years ago
Solved

Count rows based on measure

Hi,
 
I have a measure below:
New Customer = IF([Sales Last Period] = SUM('Sales'[Amount]),"Y","N")
 
Is it possible to count or sum the result from a measure without creating a calculated column?  count/sum of all Ys and Ns?
 
Thanks,
  • mb0307 add following measure for the count

     

    Count Yes Measure = 
    COUNTX ( VALUES ( Table[Customer] ), IF ( [New Customer] = "Y", 1 ) )
    
    Count No Measure = 
    COUNTX ( VALUES ( Table[Customer] ), IF ( [New Customer] = "N", 1 ) )

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

2 Replies

  • mb0307 add following measure for the count

     

    Count Yes Measure = 
    COUNTX ( VALUES ( Table[Customer] ), IF ( [New Customer] = "Y", 1 ) )
    
    Count No Measure = 
    COUNTX ( VALUES ( Table[Customer] ), IF ( [New Customer] = "N", 1 ) )

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    It is possible to do lots of things in measure w/o the use of calculated columns.  It looks like you are trying to calculate new customers.  Here is a link with one way to do that.  If you provide example data, a specific measure can be provided.

     

    https://www.sqlbi.com/articles/computing-new-customers-in-dax/

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat