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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Remco1986
Helper I
Helper I

Using Measure in chart axis, or make column instead of measure

Hi all,

after finding some great info on this forum, here's my first topic. My first part of this problem succeeded because of other topics I found, but I'm now running into an issue that I can not solve.

 

My data-set consists of a table with employees and their coaching data. Based on several columns, I have added a measure to calculate the 'Pass Rate'.

 

I have created a measure that will calculate the percentiles for 25, 50 and 75, and then returns a text for whatever wuartile their pass rate falls in:

 

Quartile = 
    var p25 = PERCENTILEX.INC(SUMMARIZE(ALLSELECTED(myTable,[Employee Name],"Pass Rate",[(%) Pass Rate]),[Pass Rate],0.25)
    var p50 = PERCENTILEX.INC(SUMMARIZE(ALLSELECTED(myTable),[Employee Name],"Pass Rate",[(%) Pass Rate]),[Pass Rate],0.5)
    var p75 = PERCENTILEX.INC(SUMMARIZE(ALLSELECTED(myTable),[Employee Name],"Pass Rate",[(%) Pass Rate]),[Pass Rate],0.75)
    return IF([(%) Pass Rate]>=p75,"Quartile 1",IF([(%) Pass Rate]>=p50,"Quartile 2",IF([(%) Pass Rate]>=p25,"Quartile 3","Outliers")))

 

 

This was a personal break-through after several nights of reading and trying. I now have a nice table like:

Employee Name(%) Pass RateQuartile
Emp1100%Quartile 1
Emp290%Quartile 2
Emp330%Outliers

 

Next step is to create a small graph with the count of employees per Quartile, however. I can not use my Quartile measure in the Axis part of the graph. I tried to use the same calculation but now as a Column instead of a measure, this results in the graph only displaying 'Quartile 2', probably because it's not yet grouped by Employee Name?

 

I also tried to create a column like so:

 

Quartile_text = switch([QuartileNumber],1,"1",2,"2",3,"3",4,"4")

 

 but this also returns only "2"

 

What would be the approach to get a 'Quartile Text' column/measure that I can use in a graph Axis, that shows all Quartiles that are also in the 'Employee Table'?

1 ACCEPTED SOLUTION
3 REPLIES 3
Pragati11
Super User
Super User

HI @Remco1986 ,

 

Here is a very nice article on how you can use a measure as an axis:

https://radacad.com/dax-measure-in-the-axis-of-the-power-bi-report

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

@amitchandak thanks, these links were very usefull.

 

I have now made a table (called 'quartileMap' with the Quartile texts and the sort-order:

quartileNamesortOrder
Quartile 11
Quartile 22
Quartile 33
Outliers4

 

Next, I created a measure:

 

 

Test = 
    SWITCH(SELECTEDVALUE(quartileMap[quartileName]),
        "Quartile 1",   COUNTROWS(filter(SUMMARIZE(ALLSELECTED(myTable),[Employee Name],"Quartile",[Quartile]),[Quartile]="Quartile 1")),
        "Quartile 2",   COUNTROWS(filter(SUMMARIZE(ALLSELECTED(myTable),[Employee Name],"Quartile",[Quartile]),[Quartile]="Quartile 2")),
        "Quartile 3",   COUNTROWS(filter(SUMMARIZE(ALLSELECTED(myTable),[Employee Name],"Quartile",[Quartile]),[Quartile]="Quartile 3")),
        "Outliers",     COUNTROWS(filter(SUMMARIZE(ALLSELECTED(myTable),[Employee Name],"Quartile",[Quartile]),[Quartile]="Outliers"))
    )

 

 

 

I can now create a bar graph with the quartileName from the quartileMap table in the Axis, and the Test measure as values.

 

Only thing is that the Quartile axis is not sorting by sortOrder, but alphabetically, causing Outliers to appear before Quartile 1, 2, 3. Instead of after Quartile 1, 2, 3. Not sure what the sortOrder does in this table. Never mind this last part, I had to select the quartileName column and sort it by sortOrder

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors