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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors