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

¿How i can calculate average of total tickets by date to show in table?

Dear all,

 

I need help to can calculate average of qty of tickets by date and show in a table with some filters: 

 

So, i have it data:

 

TICKETPLANDATECATEGORYTYPE
6-00000819PLAN 12017-07-06COMBUSTIBLEADITIONAL
6-00000810PLAN 32017-07-06MAYBE COMBUSTIBLEADITIONAL
6-00000802PLAN 32017-07-06COMBUSTIBLEADITIONAL
6-00000797PLAN 22017-07-06COMBUSTIBLE 
6-00000791PLAN 32017-07-06NO COMBUSTIBLEADITIONAL
6-00000787PLAN 32017-07-06MAYBE COMBUSTIBLEADITIONAL
6-00000777PLAN 12017-07-06MAYBE COMBUSTIBLE 
6-00000822PLAN 12017-07-07COMBUSTIBLE 
6-00000812PLAN 12017-07-08MAYBE COMBUSTIBLEADITIONAL
6-00000813PLAN 22017-07-08MAYBE COMBUSTIBLEADITIONAL 
6-00000804PLAN 12017-07-08COMBUSTIBLE 
6-00000790PLAN 22017-07-08NO COMBUSTIBLEADITIONAL
6-00000780PLAN 12017-07-08MAYBE COMBUSTIBLEADITIONAL
6-00000815PLAN 12017-07-09NO COMBUSTIBLEADITIONAL
6-00000796PLAN 32017-07-09COMBUSTIBLEADITIONAL
6-00000786PLAN 12017-07-09MAYBE COMBUSTIBLEADITIONAL
6-00000781PLAN 12017-07-09MAYBE COMBUSTIBLE 
6-00000817PLAN 12017-07-10COMBUSTIBLEADITIONAL
6-00000806PLAN 32017-07-10MAYBE COMBUSTIBLEADITIONAL
6-00000793PLAN 32017-07-10NO COMBUSTIBLEADITIONAL
6-00000784PLAN 12017-07-10MAYBE COMBUSTIBLEADITIONAL
     

 

I need to get average of tickets created by date range, in this case, AVG of tickets created from 2017-07-06 to 2017-07-10 split by PLAN and with filter CATEGORY<> "COMBUSTIBLE" and TYPE="ADITIONAL", the expected table is:

 

PLANTOTALAVERAGE
PLAN 151
PLAN 220,4
PLAN 351

 

Thanks in advanceee!!! 🙂

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @JUSEGAPO

 

I created a new calculated table using the following code and got pretty close...

 

NEW TABLE  = 
GROUPBY(
        GROUPBY(
            ADDCOLUMNS(
                FILTER(
                    'Table2',
                    'Table2'[CATEGORY]<>"COMBUSTIBLE" 
                    && Table2[TYPE]="ADITIONAL"
                    ),
                "C",1),
            Table2[PLAN],
            Table2[DATE],
            "TOTAL",SUMX(CURRENTGROUP(),[C])            
            )
        ,[PLAN],
        "TOTAL",SUMX(CURRENTGROUP(),[TOTAL]),
        "AVERATE",AVERAGEX(CURRENTGROUP(),[TOTAL])
        )

I get different figures to you for both TOTAL and AVERAGE but that's because I was following your rules exactly.  In any case it should be easy to tweak.

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Phil_Seamark
Employee
Employee

Hi @JUSEGAPO

 

I created a new calculated table using the following code and got pretty close...

 

NEW TABLE  = 
GROUPBY(
        GROUPBY(
            ADDCOLUMNS(
                FILTER(
                    'Table2',
                    'Table2'[CATEGORY]<>"COMBUSTIBLE" 
                    && Table2[TYPE]="ADITIONAL"
                    ),
                "C",1),
            Table2[PLAN],
            Table2[DATE],
            "TOTAL",SUMX(CURRENTGROUP(),[C])            
            )
        ,[PLAN],
        "TOTAL",SUMX(CURRENTGROUP(),[TOTAL]),
        "AVERATE",AVERAGEX(CURRENTGROUP(),[TOTAL])
        )

I get different figures to you for both TOTAL and AVERAGE but that's because I was following your rules exactly.  In any case it should be easy to tweak.

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.