Forum Discussion

Joop_de_Bont's avatar
Joop_de_Bont
Frequent Visitor
1 year ago
Solved

Counting on row level unique values in MatrixTable

Hi, I'am new to PowerBI and like to see if what I want is possible. I have a matrix table with two row levels (Account Manager, Customer) and the count of Unique customer per month. Now I would l...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi,audreygerred ,thanks for your concern about this issue.

    Your answer is excellent!
    And I would like to share some additional solutions below.
    Hello,Joop_de_Bont .I am glad to help you.
    First of all, you need to be clear that the value of the Total column in the matrix in Power BI can not be directly modified, it itself as a non-existent data, the system is based on the logic you put into the matrix to perform the calculation of the measurement of simple aggregation operations, if the calculation of the logic of the measurement of SUM, then the total perform the same SUM, if the calculation of the logic of the measurement of DISTINCTCOUNT, then the total of the same DISTINCTCOUNT. If the measure's logic is DISTINCTCOUNT, then total performs the same DISTINCTCOUNT, and it is important to note that the logic of a complex measure is not always passed correctly to the total column, so the value of the total column may be incorrect.
    The influence on the value of the total column can be indirectly implemented in the matrix by means of ISINCPOE.
    You can get the logic of calculating Total in Power BI's matrix from the following code

    Therefore, the total column is determined not to be a value in the row field and column field filtering hierarchy and can be set to a special value (99)

    here is my test data.


    here is my test measure:

     

     

    M_Test = 
    VAR _table =
     SUMMARIZECOLUMNS ( 'TestData'[CustomerName], 'MonthTable'[MonthName] )
    RETURN
        IF (
            NOT ( ISINSCOPE ( 'TestData'[CustomerName] ) )
                && NOT ( ISINSCOPE ( 'MonthTable'[MonthName] ) ),
            [Total Month],
            COUNTX ( _table,[M_DisCount]  )
        )
    Total Month = 
    VAR _accountManger =
        MAX ( 'TestData'[AccountManager] )
    VAR _discountPerYear =
        CALCULATE (
            DISTINCTCOUNT ( 'TestData'[MonthName] ),
            FILTER ( ALL ( 'TestData' ), 'TestData'[AccountManager] = _accountManger )
        )
    RETURN
        _discountPerYear
    M_DisCount = DISTINCTCOUNT('TestData'[CustomerName])
    

     

     


    URL:

    Solved: help COUNTX - Microsoft Fabric Community


    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Carson Jian,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


  • Joop_de_Bont's avatar
    Joop_de_Bont
    1 year ago

    Thnx, It looks like what i needed.