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
mdatmain
Regular Visitor

How to aggregate measure like calculated column?

I have created a new calculated column in a table with dates called Simple Projection. Simplified, the calculated column is like this and each date has that value which can be aggregated YTD.

 

Simple Projection = 

VAR a = 10
VAR b = 20

RETURN
    a * b

 

I want to be able to change the variable "a" which is not possible with calculated columns, but is possible with measures. However, when I created the measure with the same equation, it will not aggregate (as you see the total is still 1,298.56 whereas the column total is 472,676.97). I want to get the YTD for the measure, which I do it like this for the column:

 

Simple Projection YTD =
CALCULATE(
    SUM('Table'[Simple Projection]),
    DATESYTD( 'Invoked Function'[Date] )
)
 
Doing this calculation on the measure will not return anything. 

mdatmain_0-1619119033397.png

 

 

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

Hi @mdatmain ,

You can create another new measure as below and put it on the visual to replace the previous one.

 

Measure =
SUMX (
    GROUPBY (
        'Invoked Function',
        'Invoked Function'[Date].[Month],
        'Invoked Function'[Date].[Day]
    ),
    [Projection Test YTD Forecast]
)

 

In addition, you can refer the content in the following links to get it.

Power BI Shows Incorrect Measure Total? How to fix it?

Dax for Power BI: Fixing Incorrect Measure Totals

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

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.
lbendlin
Super User
Super User

You cannot aggregate measures. You need to recompute the measure for each "row"  in your visual (ie your filter context), and separately for the totals (if present in your visual). Use functions like SUMX to achieve that.

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.