Forum Discussion

anandsoftweb's avatar
anandsoftweb
Advocate V
9 years ago
Solved

Min value count data in DAX

Hello,

 

I want dax calculation for min status value from specific Item Segment

 

below is my sample data.

 

 

IdItemSub ItemItem StatusDescription for Count the ValueExpected Result/OP In DAX As below 
1Item11100For Item 1 Min Status is 0Total Count of Status 0 = 2
1Item11111  
1Item21120For Item 2 Min Status is 0 
1Item21131  
1Item21142  
1Item31151For Item 3 Min Status is 1Total Count of Status 1 =2
1Item31162  
1Item31173  
1Item41181For Item 3 Min Status is 1 
1Item41192  
1Item51202For Item 5 Min Status is 2Total Count of Status 2 =1
1Item51213  

 

So final Out put should be in count and I would like to display in Bar Chart By Status Count like

 

Eg,

Status 0 :- 10 Count,

Status 1 :- 20 Count, 

Status 2 :- 15 Count, 

Status 3 :- 20 Count

 

From above table

 

Thanks In Advance 

 

  • Sean's avatar
    Sean
    9 years ago

    anandsoftweb

    I really think these should work! :smileyhappy:

     

    NEW Measure (Min Status) = 
    CALCULATE ( MIN ( 'NewTable'[Item Status] ), ALLEXCEPT ( 'NewTable', 'NewTable'[Item], 'NewTable'[Id] ) )
    
    NEW Measure (Count of Status) = CALCULATE ( COUNTA ( 'NewTable'[Item Status] ), FILTER ( 'NewTable', 'NewTable'[Item Status] = [NEW Measure (Min Status)] ), ALLEXCEPT ( 'NewTable', 'NewTable'[Item], NewTable[Id] ) )

     

    Good Luck!:smileyhappy:

3 Replies

  • Sean's avatar
    Sean
    Community Champion

    anandsoftweb

    These 2 Measures work with the sample data

     

    Measure (Min Status) = 
    CALCULATE ( MIN ( 'Table'[Item Status] ), ALLEXCEPT ( 'Table', 'Table'[Item] ) )
    
    Measure (Count of Status) = 
    CALCULATE (
        COUNTA ( 'Table'[Item Status] ),
        FILTER ( 'Table', 'Table'[Item Status] = [Measure (Min Status)] ),
        ALLEXCEPT ( 'Table', 'Table'[Id] )
    )

    And the results...

     

    Hope this helps!

    Good Luck! :smileyhappy:

    • anandsoftweb's avatar
      anandsoftweb
      Advocate V

       

      Sean ,

       

      Thanks for your quick reply and DAX calculation its near up to the solution, its really helpful but for multiple id and total count is not matched.

       

      Here ID should be 2,3,4.... like wise and total (Measure (Count of Status )) should be match with total Item count like as below

       

      Item 1 has Item Status 0 as a Min

      Item 2 has Item Status 1 as a Min

      Item 3 has Item Status 2 as a Min

      Item 4 has Item Status 0 as a Min 

      Item 5 has Item Status 1 as a min

       

      So

      total 5 items and I

      Item Status 0 = 2

      Item Status 1 = 2

      Item Status 2 = 1

       

      So total should be 5 at the end

       

      In sample data it works ut in case of multiple ID its not working. while selecting id

       

      I think there should be minor change in calculation so here you can help out.

       

      If possible pls help here 

       

      Thanks once again :)

       

      Note:-1 It should be distinct count  

       

      • Sean's avatar
        Sean
        Community Champion

        anandsoftweb

        I really think these should work! :smileyhappy:

         

        NEW Measure (Min Status) = 
        CALCULATE ( MIN ( 'NewTable'[Item Status] ), ALLEXCEPT ( 'NewTable', 'NewTable'[Item], 'NewTable'[Id] ) )
        
        NEW Measure (Count of Status) = CALCULATE ( COUNTA ( 'NewTable'[Item Status] ), FILTER ( 'NewTable', 'NewTable'[Item Status] = [NEW Measure (Min Status)] ), ALLEXCEPT ( 'NewTable', 'NewTable'[Item], NewTable[Id] ) )

         

        Good Luck!:smileyhappy: