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

Incorrect DAX Measure Totals in Table Visual

Hi Power BI Experts!


I am calculating Revenue per Employee as the sum of revenue time entries in the database. In cases when employees leave the company, we want to discontinue adding their time to the revenue total. 

I used the following measure to account for theat:

 
New Resource Rate*Hours =
var termination_Date = MAX(Employees[TerminationDate])
RETURN
CALCULATE(SUM(RevenueDetail[RateTimesHours]),
FILTER(RevenueDetail, RevenueDetail[Date]<=termination_Date))
 
table.png
 
It works, but the total is incorrect. I tried some of the solutions suggested to others dealing with similar issues, but no luck. 
 
Total Rate*Hours =
var termination_Date = MAX(Employee[TerminationDate])
RETURN
SUMX(
VALUES( RevenueDetail[RateTimesHours]),
IF(RevenueDetail[Date]<=termination_Date,
CALCULATE(SUM(RevenueDetail[RateTimesHours]))))
 
This returns an error "A single value for column "Date" cannot be determined..."


I appreciate your help with this!!
 

 

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @evgeniam 

I think that something along this line should get you going:

 

Measure2 =
SUMX (
    FILTER (
        'RevenueDetail',
        'RevenueDetail'[Date] <= CALCULATE ( MAX ( 'Employee'[TerminationDate] ) )
            || ISBLANK ( CALCULATE ( MAX ( 'Employee'[TerminationDate] ) ) )
    ),
    'RevenueDetail'[RateTimesHours]
)

The MAX(TerminationDate) has to be evaluated on a row-by-row-basis for the Total to calculate correctly.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

2 REPLIES 2
ImkeF
Super User
Super User

Hi @evgeniam 

I think that something along this line should get you going:

 

Measure2 =
SUMX (
    FILTER (
        'RevenueDetail',
        'RevenueDetail'[Date] <= CALCULATE ( MAX ( 'Employee'[TerminationDate] ) )
            || ISBLANK ( CALCULATE ( MAX ( 'Employee'[TerminationDate] ) ) )
    ),
    'RevenueDetail'[RateTimesHours]
)

The MAX(TerminationDate) has to be evaluated on a row-by-row-basis for the Total to calculate correctly.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeF ,

 

This works beautifully. Thank you!!!

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.