Reply
Frequent Visitor
Posts: 8
Registered: ‎11-16-2018
Accepted Solution

Incorrect Measure Total

Hi everyone!

 

Hope you can help me this time Smiley Happy

 

I am performing the analysis and I need to show the correct total of the measure.

 

Here is an  example of the table on which I am working now and the column which I should calculate. This column is a measure (actions/hours). 

 

I tried to use this formula but ot doesnt give the correct total.

 

Total test =
var Actions = DIVIDE('General'[Actions],'General'[Total Hours],0)
return if
(HASONEFILTER('General'[Person]), Actions, sumx(values('General'[Person]),actions))
 
Thank you!!

 

action per hour.PNG


Accepted Solutions
Super User
Posts: 2,205
Registered: ‎09-19-2016

Re: Incorrect Measure Total

Hi @dariadb,

 

Change you measure to something like this

Total test =
VAR Actions =
    DIVIDE ( 'General'[Actions], 'General'[Total Hours], 0 )
RETURN
    IF (
        HASONEFILTER ( 'General'[Person] ),
        Actions,
        SUMX ( ALLSELECTED ( 'General'[Person] ), Actions )
    )

 

Regards,

MFelix



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post

Highlighted
Super User
Posts: 2,205
Registered: ‎09-19-2016

Re: Incorrect Measure Total

Hi @dariadb,

 

To wha I could get from your sample file your issue is regarding the way you calculate your measures so the best way is to create the following measures:

 

Actions =
IF (
    HASONEFILTER ( Table[Name] );
    DIVIDE ( [Actions Measure]; [Hours Measure]; 0 );
    SUMX (
        ALLSELECTED ( Table[Name] );
        DIVIDE ( [Actions Measure]; [Hours Measure]; 0 )
    )
)

 

Total hours Worked Total =
IF (
    HASONEFILTER ( Table[Name] );
    [Hours Measure];
    SUMX ( ALLSELECTED ( Table[Name] ); [Hours Measure] )
)

 

 

The Actions Measure and Hours Measure are your two base measures that you can use to make the calculations.

 

Regards,

MFelix

 



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




View solution in original post


All Replies
Established Member
Posts: 183
Registered: ‎09-17-2018

Re: Incorrect Measure Total

@dariadb

 

What's the purpose of using hasonefilter formula? I think  DIVIDE('General'[Actions],'General'[Total Hours],0) can work correct.

 

Thanks and BR

Ryan

Frequent Visitor
Posts: 8
Registered: ‎11-16-2018

Re: Incorrect Measure Total

Because using just divide function it doesnt show the correct total of the column. 

As there is a Person filter (for each row) I used hasonefilter to calculate total. 

Super User
Posts: 2,205
Registered: ‎09-19-2016

Re: Incorrect Measure Total

Hi @dariadb,

 

Change you measure to something like this

Total test =
VAR Actions =
    DIVIDE ( 'General'[Actions], 'General'[Total Hours], 0 )
RETURN
    IF (
        HASONEFILTER ( 'General'[Person] ),
        Actions,
        SUMX ( ALLSELECTED ( 'General'[Person] ), Actions )
    )

 

Regards,

MFelix



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Frequent Visitor
Posts: 8
Registered: ‎11-16-2018

Re: Incorrect Measure Total

Hi @MFelix,

 

Thank you for your solution!

However it gives me a strange total:

Total.PNG

Established Member
Posts: 201
Registered: ‎07-12-2017

Re: Incorrect Measure Total

Hi @dariadb

 

Can you share some base data or the pbix

 

Regards

Affan

Frequent Visitor
Posts: 8
Registered: ‎11-16-2018

Re: Incorrect Measure Total

Unfortunately I can't share it due to confidentiality

Super User
Posts: 2,205
Registered: ‎09-19-2016

Re: Incorrect Measure Total

Hi @dariadb,

 

I send out a response to you message, please check it.

 

Regards,

Mfelix



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Highlighted
Super User
Posts: 2,205
Registered: ‎09-19-2016

Re: Incorrect Measure Total

Hi @dariadb,

 

To wha I could get from your sample file your issue is regarding the way you calculate your measures so the best way is to create the following measures:

 

Actions =
IF (
    HASONEFILTER ( Table[Name] );
    DIVIDE ( [Actions Measure]; [Hours Measure]; 0 );
    SUMX (
        ALLSELECTED ( Table[Name] );
        DIVIDE ( [Actions Measure]; [Hours Measure]; 0 )
    )
)

 

Total hours Worked Total =
IF (
    HASONEFILTER ( Table[Name] );
    [Hours Measure];
    SUMX ( ALLSELECTED ( Table[Name] ); [Hours Measure] )
)

 

 

The Actions Measure and Hours Measure are your two base measures that you can use to make the calculations.

 

Regards,

MFelix

 



Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!