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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

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!:
Power BI Cookbook Third Edition (Color)

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
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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