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
HassanAshas
Helper V
Helper V

How to create a Bar Graph using a What if Parameter in the X-Axis

Hi, I have the data of Employees and their Credit Card spends. The data contains Employees having multiple spends in the same month. 

Sample of the dataset is provided below, 

 

DateEmp_IDEmp_NameEmp_DepartmentAmount_SpentPlace  
9/16/202394Kimberly ChanSales214.57Hinton-Gomez 
9/16/202395Andrew MillerSales77.19Avery-Macdonald 
9/16/202396David JohnsonIT381.46Long-Gonzales 
11/26/202396David JohnsonIT323.46Williams, Ball and Marshall
9/16/202397Jimmy CainOperations483.69King and Sons 
10/9/202397Jimmy CainOperations474.37Jones, Richards and Montoya
10/18/202397Jimmy CainOperations61.49Weaver-Stephens 
11/25/202397Jimmy CainOperations481.56Serrano, Cochran and Tanner
12/11/202397Jimmy CainOperations270.03Hunter, Kirby and Potter
9/16/202398George TravisOperations21.63Andrade, Collier and Davenport
10/6/202398George TravisOperations135.93Stone, Wilkins and Wells
10/29/202398George TravisOperations56.76Miller Ltd  
11/1/202398George TravisOperations181.11Johnson PLC 
12/9/202398George TravisOperations497.66Chavez, Green and Ochoa
12/12/202398George TravisOperations302.66Hernandez-Lindsey 
9/16/202399Daniel HebertMarketing22.83Young, Gonzalez and Bradshaw
10/5/202399Daniel HebertMarketing78.29Morgan-Roth 
11/9/202399Daniel HebertMarketing244.62Montoya-Garrison 
11/25/202399Daniel HebertMarketing375.58Carter, Chen and Zuniga
12/4/202399Daniel HebertMarketing87.21Brown-Navarro 
9/16/2023100Jennifer ThompsonSales459.3Jones Ltd  
10/12/2023100Jennifer ThompsonSales238.13Webb, Mcdaniel and Williamson
11/4/2023100Jennifer ThompsonSales132.01Miller LLC  
11/25/2023100Jennifer ThompsonSales402.75Rodriguez and Sons 
11/28/2023100Jennifer ThompsonSales98.49Thomas-Moore 
9/16/2023101Diana SmithSales86.24Rogers-Winters 
10/15/2023101Diana SmithSales253.28Hogan Group 
11/6/2023101Diana SmithSales300.5Graham, Monroe and Bennett
12/14/2023101Diana SmithSales208.65Tucker, Hogan and Hernandez
12/14/2023101Diana SmithSales319.32Hogan-Hooper 
9/16/2023102Cassidy White DVMFinance397.39Graham Inc 
9/18/2023102Cassidy White DVMFinance140.54Williams-Woods 
10/13/2023102Cassidy White DVMFinance140.57Weaver PLC 
12/4/2023102Cassidy White DVMFinance32.41Oneill and Sons 

 

My requirement is to analyzie people who have used the Credit Card more than one time. 

I created a What-If parameter "Credit Card Used Filter" as a decimal number from 1 to 4 and added it as a slicer. I further used it in my measures so that the slicer works properly when used. 

 

This is how my report looks at the moment, 

 

HassanAshas_0-1702623653724.png

 

 

However, what I am trying to do is basically create a Bar Graph that will show "Credit Card Used" in the X-Axis (that is, 1, 2, 3 etc.) 

and then show a bar containing the number of employees that fall in those categories. For example, 4000 people used Credit Card only once, 200 used it 2 times, 50 people used it 3 times, 4 people used it 4 times and maybe one more thing that we can add is -> 3 people used it 4+ times.

 

So what I need in my X-Axis is: 1, 2, 3, 4, 4+ 

What I need in my Y-Axis is: Total Employees falling in that category for the given set of filters (Year, Month, Department etc.) 

 

Anyone here who can help in achieving this? Thanks. 

If you would like to download the Power BI file containing the sample dataset, please do so from here: https://drive.google.com/file/d/1j8rqN9jVjlUiX0o_n2uJ9yBGaGs3AyDj/view?usp=sharing

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Like this?

lbendlin_0-1702924851208.png

You may also want to take it easy on the What-If parameters.  They include a measure for a reason.

 

see attached.

 

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

Like this?

lbendlin_0-1702924851208.png

You may also want to take it easy on the What-If parameters.  They include a measure for a reason.

 

see attached.

 

@lbendlin  Exactly like this! Thank you so much! 

How would you do it with the help of measure, by the way? Would love to know if you have a bit of time, would appreciate that. 

I would always do it with the measure rather than What-If Parameter because measures are easier to handle but I don't think this is achievable through a measure (because you can't place a Measure on the X-Axis?) 
And also, you can't really have a measure as a slicer

Like in my proposal you have to prepare a static table with all possible measure values. Then you can use that for the x axis etc.

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.