Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Peter65f1
New Member

Calculate all invoices except "Cancelled"

Hi, 

 

I am very new to DAX and Power Pivot and I'm trying to build a measure where I count all the invoices with status "open", "sent", "paid" and "overdue". I want my measure to ignore "cancelled" status of invoices. 

 

I created this, but I am worried that it's inefficient because it uses Filter funcion in my measure. 

=CALCULATE(SUM(f_invoices[revenue_czk]),

   FILTER(f_invoices,

      f_invoices[invoice_status]= "open" ||

      f_invoices[invoice_status]= "paid" ||

      f_invoices[invoice_status]= "sent" ||

      f_invoices[invoice_status]= "overdue"

))

 

Is it OK to use filter in such scenario or would you suggest something to make my measure more simple and resources efficient? 

Thank you 🙏 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Peter65f1 

it is OK. 

you may make it more concise like this

measure = 
CALCULATE(
    SUM(f_invoices[revenue_czk]),
        f_invoices[invoice_status] IN  {"open", "paid", "sent" , "overdue"}
)
or
measure =
CALCULATE(
SUM(f_invoices[revenue_czk]),
f_invoices[invoice_status] <> "cancelled"
)

View solution in original post

2 REPLIES 2
Peter65f1
New Member

Thank you, the second one is very ellegant because it takes care of potential new invoice statuses in the future. Great solution, have a great day 😊 

FreemanZ
Super User
Super User

hi @Peter65f1 

it is OK. 

you may make it more concise like this

measure = 
CALCULATE(
    SUM(f_invoices[revenue_czk]),
        f_invoices[invoice_status] IN  {"open", "paid", "sent" , "overdue"}
)
or
measure =
CALCULATE(
SUM(f_invoices[revenue_czk]),
f_invoices[invoice_status] <> "cancelled"
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors