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
mvelazquez
Frequent Visitor

"Calculate" Formula with different filters from the same column

Hello PowerBI Masters! Hope all is well.

 

So I have a table with different types of premiums with their respective values.

ID         Premium           Value

1        InvoicePrem         500

2          AO Prem             100

3         Inst Prem              50

4        EXP Prem             250

5          Prem                   300

 

What Im trying to do is basically add all the premiums for ID's only equal 1,3,4

I know I can create 3 different measures and add them up at the end or just basically use the filters tab, but is there a faster way to incorporate all the ID's within the same formula? For example something like this:

 

TestingPrem = CALCULATE(SUM(TRANS_BROKER[Value]),TRANS_BROKER[ID]= 1,3,4)   -----> This is giving me an error
 
Any help will be greatly appreciated!
Thank you 😄
2 ACCEPTED SOLUTIONS
PANDAmonium
Resolver III
Resolver III

You can use CALCULATE with FITER and nested OR functions. So something like this:
 
Measure = CALCULATE(SUM('Table'[Column2]), FILTER('Table', OR( OR ('Table'[Column1] = 1, 'Table'[Column1] = 3), 'Table'[Column1] = 4)))
 

View solution in original post

v-frfei-msft
Community Support
Community Support

Hi @mvelazquez ,

 

Measure = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER ( 'Table', 'Table'[ID] = 1 || 'Table'[ID] = 3 || 'Table'[ID] = 4 )
)

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @mvelazquez ,

 

Measure = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER ( 'Table', 'Table'[ID] = 1 || 'Table'[ID] = 3 || 'Table'[ID] = 4 )
)

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
danextian
Super User
Super User

Since OR function accepts just two arguments you can use double "|" so your formula should go something like this: 

CALCULATE (
    SUM ( TRANS_BROKER[Value] ),
    FILTER (
        TRANS_BROKER,
        TRANS_BROKER[ID] = 1
            || TRANS_BROKER[ID] = 3
            || TRANS_BROKER[ID] = 4
    )
)









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
PANDAmonium
Resolver III
Resolver III

You can use CALCULATE with FITER and nested OR functions. So something like this:
 
Measure = CALCULATE(SUM('Table'[Column2]), FILTER('Table', OR( OR ('Table'[Column1] = 1, 'Table'[Column1] = 3), 'Table'[Column1] = 4)))
 

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.