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
mastiki
Employee
Employee

Subject: Measure as x-axis of the chart

Hello, 

 

I am trying to show some dynamic histograms in Power BI, that depend on time range selected within a time slicer. For example, I have a following dataset: 

Date                Customer   Is_Active

10-10-2019     Cust1          Yes

10-10-2019     Cust2          No

10-10-2019     Cust3          Yes

10-09-2019     Cust1          Yes

10-09-2019     Cust2          No

10-09-2019     Cust3          No

10-08-2019     Cust1          No

10-08-2019     Cust2          No

10-08-2019     Cust3          Yes

etc ....

 

I have the slicer for Date. 

The histogram I am trying to show has the following axes:

x-axis: percentage of days a customer was active within a time range selected in the slicer Date (with the following bins: 0-10%, 10-20%, 20-30%, ... , 90-100%)

y-axis: percentage of customers that belong to the corresponding bin on the x-axis

 

I've calculated the necessary measures, but unfortunately, Power BI doesn't allow measures on x-axis of the bar chart. Is there any workaround for this specific case? 

 

Thank you. 

 

2 REPLIES 2
amitchandak
Super User
Super User

I am not sure I got it completely. But if you have created bins then either a clustered bar chart or clustered column chart should work.

If both are numeric the bubble is on the char allow both numeric axis. I doubt there is a seeded X-Y chart there.

So far, I've calculated the following measures for CustomersTotals table that I've desribed in the original post (Date, Customer,Is_Active

 

ActiveNum = CALCULATE(COUNT(CustomersTotals[Is_Active]),CustomersTotals[Is_Active]="Yes")
 
InactiveNum = CALCULATE(COUNT(CustomersTotals[Is_Active]),CustomersTotals[Is_Active]="No")
 
PercentActive = CustomersTotals[ActiveNum] * 100.0 / (CustomersTotals[ActiveNum] + CustomersTotals[InactiveNum])
 
PercentActive_bin = if([PercentActive] = 0, 0, if([PercentActive] > 0 && [PercentActive] <= 10, 10, if([PercentActive] > 10 && [PercentActive] <= 20, 20, if([PercentActive] > 20 && [PercentActive] <= 30, 30, if([PercentActive] > 30 && [PercentActive] <= 40, 40, if([PercentActive] > 40 && [PercentActive] <= 50, 50, if([PercentActive] > 50 && [PercentActive] <= 60, 60, if([PercentActive] > 60 && [PercentActive] <= 70, 70, if([PercentActive] > 70 && [PercentActive] <= 80, 80, if([PercentActive] > 80 && [PercentActive] <= 90, 90, 100))))))))))
 
What I would like to show on the barchart plot is PercentActive_bin on the x-axis and count(Customer) on the y-axis (with percent of grand total option turned on for the y-axis).
 
Lastly, the barchart should be dynamic depending on the timeslicer Date.
 
However, Power BI doesn't support measures to be on the x-axis, so I need a workaround for this. 
 
Thanks,
Maja
 

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.