Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Calculated column DAX

Hi,

 

I have below table and wanted to create calculated column as expected results in the box.

 

Any help.

Sr NoProductOrder DateApple qtySamsung QtyNokia qtyCalculated Column
1Apple01-Jan-2410  2
2Samsung01-Jan-24 20 2
3Apple02-Jan-2450  3
4Samsung02-Jan-24 30 3
5Nokia02-Jan-24  253
6Apple03-Jan-2420  3
7Samsung03-Jan-24 100 3
8Nokia03-Jan-24  503
  • Anonymous So like this?

    Column = 
        VAR __Date = [Order Date]
        VAR __Table = FILTER( 'Table', [Order Date] = __Date ) )
        VAR __Result = COUNTROWS( DISTINCT( SELECTCOLUMNS( __Table, "Product", [Product] ) ) )
    RETURN
        __Result

5 Replies

  • Hi Anonymous 

     

    I'm assuming you want to find the number of order lines per date.

     

    MyColumn = 
    VAR _Curr = [Order Date]
    VAR _Result =
        CALCULATE(
            COUNTROWS(
                ALLSELECTED( 'Table' )
            ),
            'Table'[Order Date] = _Curr
        )
    RETURN
        _Result
    

     

    Let me know if you have any questions.

     

    Thimma_pbi.pbix

     

  • Maybe this?

    Column = 
    CALCULATE(
        COUNT('Table'[Sr No]),
        ALLEXCEPT('Table', 'Table'[Order Date])
    )
  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Here's one more solution, PBIX is attached.

    Column = 
        VAR __Date = [Order Date]
        VAR __Result = COUNTROWS( FILTER( 'Table', [Order Date] = __Date ) )
    RETURN
        __Result
    • Anonymous's avatar
      Anonymous
      Not applicable

      actually, calculated column should count on number of products and based on the corresponding date. if apple and samsung present data in some other day that should give value on that day only.

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Anonymous So like this?

        Column = 
            VAR __Date = [Order Date]
            VAR __Table = FILTER( 'Table', [Order Date] = __Date ) )
            VAR __Result = COUNTROWS( DISTINCT( SELECTCOLUMNS( __Table, "Product", [Product] ) ) )
        RETURN
            __Result