Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Total without average

Hi,

 

I would like some help on a tricky case :

In my dashboard, I had to create this measure :

Measure = (sum('Time'[Hours])/8*'People'[Rate])/COUNT('People'[Name])

 

The point is :

-In the first table (Time), I have names, dates, and hours. For one name, there are many rows, with different dates and hours.

-In the second table (People), I have names and rates. For one name, there is one row with the associated rate.

-The two tables are linked in Power BI on the names.

-The measure is calculating a fine by day, by people.

 

Problem is, when I put the measure in a table with dates, the total by date is wrong.

I know it comes from the different rates : if I keep two people with the same rate, the total is ok, and if I keep two people of different rates, then the total is wrong (I mean different than a total of the two rows), because the calculation is made with an average of the two rates.

 

I've searched a solution for this, such as this one : https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376#

Problem is : nothing I tried worked : Summarize, Hasonefilter, Calculate...

Even if I can get the measure working with calculate or hasonefilter, the total keeps using an average for the rates.

 

Can anyone help on this case ?

 

Best regards,

 

Martin.

1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

You may modify the measure as below. The pbix file is attached in the end.

Sum Measure = 
SUMX(
    SUMMARIZE(
        Table1,
        Table1[Name],
        Table1[Date],
        "Result",
        DIVIDE(
            DIVIDE(
                SUM(Table1[Hours]),
                8
            )*
            SUM(Table2[Rate]),
            COUNT(
                Table2[Name]
            )
        )
    ),
    [Result]
)

 

Result:

a1.png

 

Best Regards

Allan

 

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

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Share a small dataset and sho the expected result.  paste the tables in a format that can be taken to an MS Excel file. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table1:

d1.png

 

Table2:

d2.png

 

Realtionship:

d3.png

 

Measure:

Measure = 
DIVIDE(
    DIVIDE(
        SUM(Table1[Hours]),
        8
    )*
    SUM(Table2[Rate]),
    COUNT(
        Table2[Name]
    )
)

 

You may create a new measure as below.

Avg Measure = 
AVERAGEX(
    SUMMARIZE(
        Table1,
        Table1[Name],
        Table1[Date],
        "Result",
        DIVIDE(
            DIVIDE(
                SUM(Table1[Hours]),
                8
            )*
            SUM(Table2[Rate]),
            COUNT(
                Table2[Name]
            )
        )
    ),
    [Result]
)

 

Result:

d4.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Hi Alan,

 

Thank you for your help.

 

Unfortunately, the solution doesn't work : if I build a table with Name and Measure, I get 0,63 for a, 0,20 for b, and 1,50 for c. The total should be 2,33, but we get 2,05.

 

Is there a way to calculate the measure to get 2,33 as total ?

 

Best regards,

 

Martin.

Hi, @Anonymous 

 

You may modify the measure as below. The pbix file is attached in the end.

Sum Measure = 
SUMX(
    SUMMARIZE(
        Table1,
        Table1[Name],
        Table1[Date],
        "Result",
        DIVIDE(
            DIVIDE(
                SUM(Table1[Hours]),
                8
            )*
            SUM(Table2[Rate]),
            COUNT(
                Table2[Name]
            )
        )
    ),
    [Result]
)

 

Result:

a1.png

 

Best Regards

Allan

 

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

Anonymous
Not applicable

Hi Alan,

 

It's perfect ! Thanks a lot !

 

Best regards,

 

Martin.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.