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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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!:
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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.