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
Anonymous
Not applicable

Filtering years within a measure

I am using a measure to calculate a value within a matrix, which is then presented for both 2018 and 2019. 

Extended Revenue divided by INVOICE_QTY =
DIVIDE(
    SUM('WEEKLY_INVOICE_REGISTER_DETAIL'[EXT Revenues]),
    SUM('WEEKLY_INVOICE_REGISTER_DETAIL'[INVOICE_QTY]))

 

I want another measure to find the difference between between the two values for 2018 and 2019. I have a date heirarchy for years set up as the columns in my table. I tried:

 
'2019-2018 Revenue Difference = CALCULATE(CALCULATE(
[Extended Revenue divided by INVOICE_QTY] , 'WEEKLY Tbl_MV_TM_INVOICE_REGISTER_DETAIL'[GL_YEAR]= "2019") - (CALCULATE(
[Extended Revenue divided by INVOICE_QTY] , 'WEEKLY Tbl_MV_TM_INVOICE_REGISTER_DETAIL'[GL_YEAR] = "2018")))
 
But its subtracting each yearly value from 0.
 
Thanks!
1 ACCEPTED SOLUTION

Hi @Anonymous ,

Not quite sure what your data model looks like, maybe you can try the following measure:

'2019-2018 Revenue Difference =
IF (
    ISINSCOPE ( WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Quarter] ),
    BLANK (),
    CALCULATE ( [Extended Revenue divided by INVOICE_QTY] )
        - CALCULATE (
            [Extended Revenue divided by INVOICE_QTY],
            FILTER (
                ALLSELECTED ( WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Year] ),
                WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Year]
                    < MAX ( WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Year] )
            )
        )
)

Here is a demo, please try it:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EYIzmQIx0LJCrs-fuogh37gBSxi4dG1ekgTTw_ZWonO4Tw?e=PHyhcC 

If not your case, kindly share your sample pbix file if you don't have any Confidential Information.

Best Regards,

Community Support Team _ Joey
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

3 REPLIES 3
Nathaniel_C
Super User
Super User

 

Hi @Anonymous ,
If you break this into two measures, do they work? If you attach the following portion to a card, is it accurate?

CALCULATE(
[Extended Revenue divided by INVOICE_QTY] , 'WEEKLY Tbl_MV_TM_INVOICE_REGISTER_DETAIL'[GL_YEAR]= "2019")


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 





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

Proud to be a Super User!




Anonymous
Not applicable

Hi @Nathaniel_C ,

Thanks for the quick reply! This works great if I create a separate table and have both the 2018, 2019, and difference. When I put the difference measure into our main table it subtracts 0 from the 2019 value and the 2018 value from 0. I think this is because the matrix is using a date heirarchy, how would you access the year value within that into the individual revenue formulas?

 

 

Hi @Anonymous ,

Not quite sure what your data model looks like, maybe you can try the following measure:

'2019-2018 Revenue Difference =
IF (
    ISINSCOPE ( WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Quarter] ),
    BLANK (),
    CALCULATE ( [Extended Revenue divided by INVOICE_QTY] )
        - CALCULATE (
            [Extended Revenue divided by INVOICE_QTY],
            FILTER (
                ALLSELECTED ( WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Year] ),
                WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Year]
                    < MAX ( WEEKLY_INVOICE_REGISTER_DETAIL[Date].[Year] )
            )
        )
)

Here is a demo, please try it:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EYIzmQIx0LJCrs-fuogh37gBSxi4dG1ekgTTw_ZWonO4Tw?e=PHyhcC 

If not your case, kindly share your sample pbix file if you don't have any Confidential Information.

Best Regards,

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

 

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.