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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Problems creating a specific measure

Hello all,

 

I'm having some difficulties to implment a measure or a workaround to do the following:

I need to implement a stacked bar chart to see the "Executed Quantity Batch by Operator".

In the axis I have the operator but my problem is to create a measure to calculate the rest.

 

In sql I have the following table (the data is not complete, it's just for the example):

IdDimVoiceOperator_idDimStartDate_idBatchNumberFactTaskExecution_id
117943908/07/202162717
117944908/07/202162717
118016908/07/202122774
118017908/07/202112774
118018908/07/202122774
118158908/07/202112787
118159908/07/202112787
118160908/07/202112787
118161908/07/202112787
118204908/07/202112802
118205908/07/202112802
118206908/07/202112802

 

And in my sql query I have the following which gives me the expected result:

select sum(batch) from (
select count(distinct(batchnumber)) as batch
FROM [Sonae.Voice.202x].[dbo].[FactTaskDetailExecution]
where DimStartDate_id = '2021-07-08' and DimVoiceOperator_id = 9
group by FactTaskExecution_id) as total

 

The where clause I have the operator in the Axis of the chart and the date is in a slicer so I just need to understand how to apply the sum, the count and the group by.

 

Can anyone have some tips on this?

 

Best regards,

Rui Santos

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

What you need is a Sumx of the Distinct count, forgive the bad measure name

sumx distinct count = SUMX(VALUES('Table'[FactTaskExecution_id]), [Distinct Batch Count])

Again pbix sample attached

 

 

richbenmintz_0-1625753951627.png

 



I hope this helps,
Richard

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

Proud to be a Super User!


View solution in original post

9 REPLIES 9
DemoFour
Responsive Resident
Responsive Resident

Hi @Anonymous 

 

Can you confirm this data table is right and what it is you want to achive please. 

 

Data.png

Anonymous
Not applicable

Hello, @DemoFour 

 

I want to show in one stack bar chart the Executed Batches By Operator. Looking at the data the expected result should be:

  • 1 distinct for FactTaskExecution_id = 2717
  • 2 disctinct for FactTaskExecution_id = 2774
  • 1 distinct for FactTaskExecution_id = 2787
  • 1 distinct for FactTaskExecution_id = 2802

So the final result should be the sum of the above values which is 5.

 

However using just the distinctcount is not enough because different FactTaskExecution_id can have the same batchnumber and I want the sum of them. Don't know if you understand..

 

Thanks,

Rui

richbenmintz
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Making some assumptions on the Visual requirement, the following measure provides the distinct count of Batches

Distinct Batch Count = DISTINCTCOUNT('Table'[BatchNumber])

Resulting in the following visual

richbenmintz_0-1625752636819.png

Attached please find a simple sample file

Thanks,



I hope this helps,
Richard

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

Proud to be a Super User!


Anonymous
Not applicable

@richbenmintz 

 

Thanks, it's almost there. I just need to group by the FactTaskExecution_id becaus if batchnumber = 1 in two different FactTaskExecution_id it should count as well if you know what I mean.

 

Thank you.

Rui

Hi @Anonymous 

 

What you need is a Sumx of the Distinct count, forgive the bad measure name

sumx distinct count = SUMX(VALUES('Table'[FactTaskExecution_id]), [Distinct Batch Count])

Again pbix sample attached

 

 

richbenmintz_0-1625753951627.png

 



I hope this helps,
Richard

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

Proud to be a Super User!


Anonymous
Not applicable

Hi @richbenmintz 

 

You're legend. Thanks for the solution. I was not getting there for nothing. Need to start thinking when I need 2 measures or something. I'm trying to create always one.

 

Thank you very much.

Have a nice day.

Rui

Hi @Anonymous,

 

You are most welcome, I would imagine you could get the same result using a single measure and storing the intitial distinct count in a variable.

 

Thanks,



I hope this helps,
Richard

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

Proud to be a Super User!


richbenmintz
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Can you provide an expected outcome for you visual please?



I hope this helps,
Richard

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

Proud to be a Super User!


Anonymous
Not applicable

Hello @richbenmintz ,

 

Thanks for you quick reply.

Yes, looking at that data the result should be:

  • 1 distinct for FactTaskExecution_id = 2717
  • 2 disctinct for FactTaskExecution_id = 2774
  • 1 distinct for FactTaskExecution_id = 2787
  • 1 distinct for FactTaskExecution_id = 2802

So the final result should be the sum of the above values which is 5.

 

Regards,

Rui

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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