Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Thimma_pbi
Helper I
Helper I

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
1 ACCEPTED SOLUTION

@Thimma_pbi 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


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@Thimma_pbi Here's one more solution, PBIX is attached.

Column = 
    VAR __Date = [Order Date]
    VAR __Result = COUNTROWS( FILTER( 'Table', [Order Date] = __Date ) )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.

@Thimma_pbi 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


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
jgeddes
Super User
Super User

Maybe this?

Column = 
CALCULATE(
    COUNT('Table'[Sr No]),
    ALLEXCEPT('Table', 'Table'[Order Date])
)




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

Proud to be a Super User!





gmsamborn
Super User
Super User

Hi @Thimma_pbi 

 

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

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.