Forum Discussion
Dynamic results based on slicer selection
Hi Community Experts,
I am looking for help with this data source in Power BI.
Now, based on how i select the start date and end date on slicer "Date Selection" which comes from first column "Date", I want it to show the number of employees who were away in days away bracket such as 0-3 days, 4-5 days or >5 days. And the results could be different, as you see below, based on date selection
Please help demonstrate or enlist steps. Power Bi file attached here:- https://drive.google.com/file/d/1fQEx2thrmHiGog3Oix-okksnwK9MdNAd/view?usp=sharing
Anonymous
I have tried to implement your scenario.
Created a static table. [Category]
Created a DAX measure
Employees = VAR __Table = SUMMARIZE ( RawData, RawData[Employee ID], "Count", COUNT ( RawData[Employee ID] ) ) VAR __TableWithGroup = ADDCOLUMNS ( __Table, "Days Group", SWITCH ( TRUE (), [Count] > 0 && [Count] <= 3, "0-3", [Count] > 3 && [Count] <= 5, "4-5", ">5" ) ) VAR __selectedGroup = SELECTEDVALUE ( Category[Days Away Group] ) VAR __TotalEmployees = COUNTX ( __Table, [Employee ID] ) VAR __CategoryWiseCount = COUNTX ( FILTER ( __TableWithGroup, [Days Group] = __selectedGroup ), RawData[Employee ID] ) VAR __result = IF ( ISBLANK ( __selectedGroup ), __TotalEmployees, __CategoryWiseCount ) RETURN IF ( ISBLANK ( __result ), 0, __result )Use the Days Away Group column from Category table and newly created measure into the table visual
Attaching the PBIX file for your reference.
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂You think it's duplicated with the post below.
https://community.powerbi.com/t5/Desktop/Dynamic-results-based-on-slicer-selection/m-p/1305440
7 Replies
- nandukrishnavs
Community Champion
Anonymous
I have tried to implement your scenario.
Created a static table. [Category]
Created a DAX measure
Employees = VAR __Table = SUMMARIZE ( RawData, RawData[Employee ID], "Count", COUNT ( RawData[Employee ID] ) ) VAR __TableWithGroup = ADDCOLUMNS ( __Table, "Days Group", SWITCH ( TRUE (), [Count] > 0 && [Count] <= 3, "0-3", [Count] > 3 && [Count] <= 5, "4-5", ">5" ) ) VAR __selectedGroup = SELECTEDVALUE ( Category[Days Away Group] ) VAR __TotalEmployees = COUNTX ( __Table, [Employee ID] ) VAR __CategoryWiseCount = COUNTX ( FILTER ( __TableWithGroup, [Days Group] = __selectedGroup ), RawData[Employee ID] ) VAR __result = IF ( ISBLANK ( __selectedGroup ), __TotalEmployees, __CategoryWiseCount ) RETURN IF ( ISBLANK ( __result ), 0, __result )Use the Days Away Group column from Category table and newly created measure into the table visual
Attaching the PBIX file for your reference.
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂 - v-alq-msft
Community Support
Hi, Anonymous
Based on your description, you may create a new table as below. The pbix file is attached in the end.
Table:
You may create a measure as below.
Employees = var tab = SUMMARIZE( ALLSELECTED(RawData), RawData[Employee ID], "Num",DISTINCTCOUNT(RawData[Date]) ) var newtab = ADDCOLUMNS( 'Table', "Count", SWITCH( [Days Away Group], "0-3", COUNTROWS( FILTER( tab, [Num]>=0&&[Num]<=3 ) ), "4-5", COUNTROWS( FILTER( tab, [Num]>=4&&[Num]<=5 ) ), ">5", COUNTROWS( FILTER( tab, [Num]>5 ) ) ) ) var result= SUMX( newtab, [Count] ) return IF( ISBLANK(result), 0, result )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Thanks v-alq-msft., nandukrishnavs
Both solutions worked and helped me complete this task
- AnonymousNot applicable
Hi Community Experts,
I have this data below from my source.
I want a slicer on my Date field and based upon that slicer selection, i want a table which would tell me how many employees employees were away on travel for 0-3 days or 4-5 days or >5 days. Practical scenario of above example below based on different date slicer selection-
Date Selection Slicer Date Selection Slicer Start Date End Date Start Date End Date 10/21/2019 11/23/2019 10/21/2019 11/21/2019 Days Away Group Employees Days Away Group Employees 0-3 0 0-3 0 4-5 0 4-5 1 >5 2 >5 1 I am also attaching the Power BI file, would be great if someone can help demonstrate or enlist steps here for me to follow. Thanks
https://drive.google.com/file/d/1fQEx2thrmHiGog3Oix-okksnwK9MdNAd/view?usp=sharing
- MFelix
Super User
You think it's duplicated with the post below.
https://community.powerbi.com/t5/Desktop/Dynamic-results-based-on-slicer-selection/m-p/1305440
- AnonymousNot applicable
MFelix Thanks,
When i posted the question first, i did not see it under th discussion forum.
So, i had to write it all over again. It would be a bug or a miss from my side.