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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Benedictmooray
Frequent Visitor

Subtraction of 3 measures with a condition

Hi all, 

 

I need some quick help please. I need to change a calculation with the following logic:

 

All expenses with a status "commit" minus all the expenses with a status "unap" and minus all resource labelled "org" where that "org" expense is within the next 5 months. 

Org expense within the next 5 months is defined as current month + next 5 month e.g if it is Dec currently then it should be December + next 5 months, which will be till May.


Help will be much appreciated.


Thanks

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Benedictmooray ,

You can create a measure as below to get it:

measure =
VAR _commit =
    CALCULATE (
        SUM ( 'Table'[Expense] ),
        FILTER ( 'Table', 'Table'[status] = "commit" )
    )
VAR _unap =
    CALCULATE (
        SUM ( 'Table'[Expense] ),
        FILTER ( 'Table', 'Table'[status] = "unap" )
    )
VAR _unap =
    CALCULATE (
        SUM ( 'Table'[Expense] ),
        FILTER (
            'Table',
            'Table'[status] = "org"
                && VALUE ( FORMAT ( 'Table'[Date], "YYYYMM" ) )
                    >= VALUE ( FORMAT ( TODAY (), "YYYYMM" ) )
                && VALUE ( FORMAT ( 'Table'[Date], "YYYYMM" ) ) <= EOMONTH ( TODAY (), 5 )
        )
    )
RETURN
    _commit - _unap - _unap

If the above one can't help you get the expected result, please provide some raw data in your tables   (exclude sensitive data) with Text format and your visual settings. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Benedictmooray ,

You can create a measure as below to get it:

measure =
VAR _commit =
    CALCULATE (
        SUM ( 'Table'[Expense] ),
        FILTER ( 'Table', 'Table'[status] = "commit" )
    )
VAR _unap =
    CALCULATE (
        SUM ( 'Table'[Expense] ),
        FILTER ( 'Table', 'Table'[status] = "unap" )
    )
VAR _unap =
    CALCULATE (
        SUM ( 'Table'[Expense] ),
        FILTER (
            'Table',
            'Table'[status] = "org"
                && VALUE ( FORMAT ( 'Table'[Date], "YYYYMM" ) )
                    >= VALUE ( FORMAT ( TODAY (), "YYYYMM" ) )
                && VALUE ( FORMAT ( 'Table'[Date], "YYYYMM" ) ) <= EOMONTH ( TODAY (), 5 )
        )
    )
RETURN
    _commit - _unap - _unap

If the above one can't help you get the expected result, please provide some raw data in your tables   (exclude sensitive data) with Text format and your visual settings. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @Benedictmooray ,

 

Without any data is difficult to give you a correct answer.

 

Can you please share a mockup data or sample of your PBIX file with expected result. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.