Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have below table and wanted to create calculated column as expected results in the box.
Any help.
Sr No | Product | Order Date | Apple qty | Samsung Qty | Nokia qty | Calculated Column |
1 | Apple | 01-Jan-24 | 10 | 2 | ||
2 | Samsung | 01-Jan-24 | 20 | 2 | ||
3 | Apple | 02-Jan-24 | 50 | 3 | ||
4 | Samsung | 02-Jan-24 | 30 | 3 | ||
5 | Nokia | 02-Jan-24 | 25 | 3 | ||
6 | Apple | 03-Jan-24 | 20 | 3 | ||
7 | Samsung | 03-Jan-24 | 100 | 3 | ||
8 | Nokia | 03-Jan-24 | 50 | 3 |
Solved! Go to 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
@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
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
Maybe this?
Column =
CALCULATE(
COUNT('Table'[Sr No]),
ALLEXCEPT('Table', 'Table'[Order Date])
)
Proud to be a 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.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
18 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |