Forum Discussion

baneworth's avatar
baneworth
Helper III
5 years ago
Solved

Issue with Matrix and AVG calulcation

Hello,

 

I have a Report with a flaw where modules are counted daily (MO-FR) and then the monthly AVG is then used for Utilization Calculcation (%).

 

If you look at the screenshot below, you can see that the weekdays with no module do not show 0 (added red 0's) and therefore the AVG calculation only uses days with modules and doesnt take 0 into account which results into much higher AVG.

      - please ignore the "Bay Utilization" Matrix

 

 

I am actually overwhelmed and can not figure out how to do that. (applying it both for daily count and monthly AVG)

 

If someone could take a look at the pbix.file and give me a direction that would be amazing and i would very grateful.

- it has calculated table with index to count daily modules

 

pbix.file 

 

Best regards

Mat

  • Hi  baneworth ,

     

    Create a measure as below:

    Measure 2 = 
    var _dates=CALCULATETABLE(VALUES('Date'[Date]),FILTER(ALL('Date'),MONTH('Date'[Date])=MONTH(MAX('Date'[Date]))&&YEAR('Date'[Date])=YEAR(MAX('Date'[Date]))&&'Date'[IsWeekday]=TRUE()))
    var _days=CALCULATE(COUNTROWS(_dates),FILTER(_dates,MONTH('Date'[Date])=MONTH(MAX('Date'[Date]))&&YEAR('Date'[Date])=YEAR(MAX('Date'[Date]))))
    var _number=CALCULATE(COUNT('Calculated Table'[Index]),FILTER(ALL('Calculated Table'),'Calculated Table'[Group]=MAX('Calculated Table'[Group])&&'Calculated Table'[Date] in _dates))
    Return
    DIVIDE(_number,_days)+0
    

    And you will see:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

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

     

6 Replies

  • Angith_Nair's avatar
    Angith_Nair
    Continued Contributor

    Hi baneworth ,

    Hope you are doing good.

    I have looked into your pbix file. Try to create measure instead of plotting direct column (Count of Index) into values.

     

     

    test =
    IF (
        COUNT ( 'Calculated Table'[Index] ) > 0,
        COUNT ( 'Calculated Table'[Index] ),
        0
    )

     

     

     

    If this helps then please mark this as solution so that others can refer to it as well.

    • baneworth's avatar
      baneworth
      Helper III

      Hey Angith_Nair 

       

      That worked perfect!

      But how would i use this measure to get the AVG for month?

       

      Current AVG Formula:

       

      Sorry if this might seem obvious.

       

      BR

      • Angith_Nair's avatar
        Angith_Nair
        Continued Contributor

        baneworth 

        You can use the following measure...

         

         

         

        Average test module =
        VAR AverageValue =
            AVERAGEX (
                FILTER ( 'Date', 'Date'[IsWeekday] = TRUE () ),
                CALCULATE ( DISTINCTCOUNT ( 'Calculated Table'[Index] ) )
            )
        VAR SelectedGroup =
            SELECTEDVALUE ( 'Calculated Table'[Group] )
        RETURN
            IF ( ISBLANK ( SelectedGroup ) && ISBLANK ( AverageValue ), 0, AverageValue )

         

         

         

         

        If this helps then please mark it as a solution.

  • Hi,

    Why have you created a calculated table?  Why not drag fields from individual tables?  You may have to rebuild some relationships but i think that will be a better approach.