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
cookme97
New Member

Dynamic Spend Annualizer Based on a Slicer

Hello!

Apologies if this has been asked previously - as I am new to DAX and haven't quite found what I'm looking for.

 

Goal: To have a dynamic measure that calculates the annualized spend based on a months slicer across all categories. 
For example, say that I have the following data:

DAX_Help_1.PNG

I would like to summarize it in a table and add a measure that calculates the annualized spend (e.g., the average of all the bananas for the first four months multiplied by 12 to get the annualized average.  Or, something like this:

DAX_Help_3.PNGDAX_Help_2.PNG

 

Additionally, I would love for it to be dynamic (the annualized spend is based on slicer). So, if I have three months selected and am showing totals by category for three months, the formula might look like [(Sum of all bananas Jan - Mar)/*3 months] * 12 months. 

 

I have been experimenting with SELECTEDVALUE and SUMX but haven't quite figured it out yet. 

 

Thank you so much in advance!

 

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

Hi @cookme97 ,

 

I think you can try code as below to create a calculated column or a measure.

APR Run Rate =
VAR _COST =
    CALCULATE ( SUM ( 'Table'[Cost] ) )
VAR _COUNT =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Month] ),
        ALLEXCEPT ( 'Table', 'Table'[Category] )
    )
RETURN
    DIVIDE ( _COST, _COUNT ) * 12

Result is as below.

RicoZhou_0-1675241175483.png

 

Best Regards,
Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @cookme97 ,

 

I think you can try code as below to create a calculated column or a measure.

APR Run Rate =
VAR _COST =
    CALCULATE ( SUM ( 'Table'[Cost] ) )
VAR _COUNT =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Month] ),
        ALLEXCEPT ( 'Table', 'Table'[Category] )
    )
RETURN
    DIVIDE ( _COST, _COUNT ) * 12

Result is as below.

RicoZhou_0-1675241175483.png

 

Best Regards,
Rico Zhou

 

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

 

AlexisOlson
Super User
Super User

Try this:

SUM ( Table1[Cost] ) * DIVIDE ( 12, DISTINCTCOUNT ( Table1[Month] ) )

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.