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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

DAX Count where

Hi All,

 

Coming from a T-SQL background I am not sure of the syntax I need.

 

I need two fields in the same visual which counts the rows form the table.

 

CoffeeMobile  with OrderSource =1 and the other 'CoffeeFront' Ordersource = 0  with both using promotion id 20282 where the store like '%SA' and store in ('Broken Hill').

 

I have written the following DAX, which is missing the store requirements.

 

CoffeeFront = CALCULATE(COUNT('adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_unique_id]),FILTER('adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv','adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[promotion_id] = 20282),FILTER('adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv','adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_order_src] = 0))
CoffeeMobile = CALCULATE(COUNT('adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_unique_id]),FILTER('adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv','adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[promotion_id] = 20282),FILTER('adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv','adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_order_src] = 1))

Any aisstance would be great, Thanks

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

@Anonymous

Hi,

Which table are the stores and store locations in. If they are in a sole table, we need to create relationships with the current table. Then we add a calculated column with this formula.

 

StoreCode =
RIGHT ( Table1[Store], 2 )

 

If you can post more information, we can get more accurate formula. You can refer to the formula here for the moment. BTW, Ross73312 is quite right though missed something.

 

CoffeeFront = CALCULATE(
       COUNT(
              'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_unique_id]
       ),      
       'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[promotion_id] = 20282,
       'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_order_src] = 0,
       StoreTable[Location] = “Broken Hill”,
       StoreTable[StoreCode] = “SA”
 )

DAX Count where.JPG)

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-jiascu-msft
Microsoft Employee
Microsoft Employee

@Anonymous

 

Hi,

 

Is your problem solved? What can I do for you?

 

Best Regards!

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Microsoft Employee
Microsoft Employee

@Anonymous

Hi,

Which table are the stores and store locations in. If they are in a sole table, we need to create relationships with the current table. Then we add a calculated column with this formula.

 

StoreCode =
RIGHT ( Table1[Store], 2 )

 

If you can post more information, we can get more accurate formula. You can refer to the formula here for the moment. BTW, Ross73312 is quite right though missed something.

 

CoffeeFront = CALCULATE(
       COUNT(
              'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_unique_id]
       ),      
       'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[promotion_id] = 20282,
       'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_order_src] = 0,
       StoreTable[Location] = “Broken Hill”,
       StoreTable[StoreCode] = “SA”
 )

DAX Count where.JPG)

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

You were very close. You didn't need to add in the filter function as calculate does this already.

CoffeeFront = CALCULATE(
	COUNT(
		'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_unique_id]
	),	
	'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[promotion_id] = 20282,
	'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_order_src] = 0
)
CoffeeMobile = CALCULATE(
	COUNT(
		'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_unique_id]
	),
	'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[promotion_id] = 20282,
	'adeadhoc_20170510_203451_gma_mobile_ordering_master_filtered_de20170510_csv'[order_order_src] = 1	
)

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors