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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to keep the slicer when the slicer field is used as a groping column for other field?

 

Hello Friends,

I am having one issue with one of our reports. I need to fix it by the EOD. Please help me

 
 

problem 1.PNG

If you look at the table above, driver BRIGES, PETER, MR has worked for 11.75 hours for both HARVEST and ONEFOR customer. In the next  second hour column I have splitted that 11.75 hours into hours worked for each CUSTOMER i.e 8.18 for HARVEST and 3.19 and 0.37 for ONEFOR using the below dax

 

%Customer = DIVIDE(SUM('GTR Job Logs'[Hours]),

CALCULATE(SUM('GTR Job Logs'[Hours]), ALLSELECTED('GTR Job Logs'[Vehicle Code],'GTR Job Logs'[Customer Code],'GTR Job Logs'[Route Code])))

 

Hours to Customers = 'TLX Measures'[%Customer] * SUM('EMP Timesheet'[Hours])

 

So far it's good. 

 

Now my client wants me to add CUSTOMER(HARVEST, ONEFOR) as slicer. If I add slicer now and select any one customer, I won't be able to see the hours as in the second hour column instead it takes the hours in first column . This is because the second hour column is calculated during the run time. 

 

problem 2.PNG

 

 

But what I want is, when I click on the customer slicer, I should get the hours according to the second hour column. 

 

This is bit urgent. IF you could help me, I would be glad. Thank you so much. 

 

11 REPLIES 11
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

For your case, you need to use ALL insead of ALLSELECTED Function in your measure, please refer to this blog:

http://tinylizard.com/all-vs-allselected/

 

If you still have the problem, please share your sample pbix file for us have a test.

 

Regards,

Lin

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

Hello,

 

I have used ALL. IF I use it then my calculation Won't work as expected in the second hour column. 

hi  @Anonymous 

Please share your sample pbix file for us have a test.

 

Regards,

Lin

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

Yes, I have sent you via Message. Thank you. 

Ashish_Mathur
Super User
Super User

Hi,

When you select HARVEST, only 1 row appears for Bridges, Peter Mr.  What exact figure do you want to see in both the hour columns?  Also, how can 2 measures have the same name (hours)?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Anonymous
Not applicable

Hello,

 

The first hour column I have just added for a reference, which as taken from different table. Consequently, I am splitting that 11.75 hours into 8.18-> 3.19->.37 in the second hours column. Actually, I dont need that first hour column, I have just added for reference. 

 

When I click on HARVEST, I should see

image1.PNG

When I click on ONEFOR, I should see

image2.PNG

 

 

Anonymous
Not applicable

Hello,

 

For better understanding, what I am trying to do is. 

 

A employee PETER has worked for 11.75 hours according to EMP. Timesheet table. 

But his actual worked hours are 15.08 according to JOb Log table in which he worked for two different customers (harvest and onefor)

Now, I am trying to find the percentage of hours for each customer and then multiplying that with hours in the EMP timesheet table. Because I want % of hours for each customer from EMP timesheet table. 

Hi,

You may download my PBI file from here.  I do not have the perfect solution but am sharing with whatever i have done so far so either you/someone else can modify/simplify my formulas.

As you can see in this screenshot, when no selection of Customer code is made, then the result for Bridges Peter is correct.

Untitled.png

When HARVEST is selected in the slicer, then also the result of Bridges Peter is correct

Untitled1.png

However, when ONEFOR is selected in the slicer, then the result is incorrect

Untitled2.png

I think that the result is incorrect when ONEFOR is selected because of the additional filter conditions that you have applied in the filter pane - may be some of those are conflicting with the condition that we have selected.

Also, i think my formula is way too complicated and can definitely be simplified.

I look forward to someone else pitching in as well.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

Share the link from where i can download your PBI file.  Please share only what is relevant for solving this problem.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
MFelix
Super User
Super User

Hi @Anonymous ,

 

You are looking to keep the the hours split always the same correct so you can know what is the percentage of the time spent pwer customer right?

 

You need to use an ALL statement based on your customer column, however this depends also on the structure of your data.

Is it possible to share a sample of you model?

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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