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

Why is my total calculated incorrectly?

geleigh_0-1668774915903.png

 

My 'Recognized' column above is calculating the wrong total at the bottom. How do I fix this?

 

This column is a new measure, using the following DAX: 

Recognized = IF(Projects_Task_Workplans[BudgetHours minus ActualHours]<0,0,IF((Projects_Task_Workplans[BudgetHours minus ActualHours]-sum(Projects_Task_Workplans[ScheduledHours])>0),sum(Projects_Task_Workplans[ScheduledHours]),Projects_Task_Workplans[BudgetHours minus ActualHours]))
 
Thanks in advance!
1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @geleigh ,

 

Because of Row context is most easily thought of as the current row. It applies whenever a formula has a function that applies filters to identify a single row in a table. The function will inherently apply a row context for each row of the table over which it is filtering. This type of row context most often applies to measures.

For more information, you can refer these documentations:

Learn DAX basics in Power BI Desktop - Power BI | Microsoft Learn

Tutorial: Create your own measures in Power BI Desktop - Power BI | Microsoft Learn

Measures in Power BI Desktop - Power BI | Microsoft Learn

 

You can add a measure like this:

 

 

R =
IF (
    COUNTROWS ( VALUES ( Projects_Task_Workplans[ID] ) ) = 1,
    [Recognized],
    SUMX (
        VALUES ( Projects_Task_Workplans[ID] ),
        'Projects_Task_Workplans'[Recognized]
    )
)

 

 

The result is:

vyinliwmsft_0-1669022462344.png

 

Hope this helps you.

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

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

Hi @geleigh ,

 

Because of Row context is most easily thought of as the current row. It applies whenever a formula has a function that applies filters to identify a single row in a table. The function will inherently apply a row context for each row of the table over which it is filtering. This type of row context most often applies to measures.

For more information, you can refer these documentations:

Learn DAX basics in Power BI Desktop - Power BI | Microsoft Learn

Tutorial: Create your own measures in Power BI Desktop - Power BI | Microsoft Learn

Measures in Power BI Desktop - Power BI | Microsoft Learn

 

You can add a measure like this:

 

 

R =
IF (
    COUNTROWS ( VALUES ( Projects_Task_Workplans[ID] ) ) = 1,
    [Recognized],
    SUMX (
        VALUES ( Projects_Task_Workplans[ID] ),
        'Projects_Task_Workplans'[Recognized]
    )
)

 

 

The result is:

vyinliwmsft_0-1669022462344.png

 

Hope this helps you.

Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

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

ppm1
Solution Sage
Solution Sage

Please see this video for how to fix that - (2) Power BI - Tales from the front #01 - Getting the Right Total - YouTube

 

Pat

 

Microsoft Employee

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.