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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
adriancho_BI
Regular Visitor

Create Categories

Hi! I need your help. 
I'm trying to create a category measure, where the column I'm referencing has numers from 0 to 1. I'm trying to create a category every 25% like ranges. I cant't manually group thems because I have hundreds of thounsends differents values. Thanks Chat GPT and youtube I have these tow approaches, but no one have resolved my issue, thanks in advance for the help!

Approach 1:

IF(
    sumx(sign_up_data_device,sign_up_data_device[%_days_with_traffic]) = 0,
    "0%",
    IF(
       sumx(sign_up_data_device,sign_up_data_device[%_days_with_traffic]) <= 0.25,
        ">0 -25%",
        IF(
            sumx(sign_up_data_device,sign_up_data_device[%_days_with_traffic]) <= 0.5,
            ">25 -50%",
            IF(
                sumx(sign_up_data_device,sign_up_data_device[%_days_with_traffic]) <= 0.75,
                ">50 -75%",
                IF(
                    sumx(sign_up_data_device,sign_up_data_device[%_days_with_traffic]) > 0.75,
                    ">75-100%",
                    "0%"
                )
            )
        )
    )
)
 
Approach 2:
% Days with Traffic (Range) = VAR TrafficPercentage = SUMX(sign_up_data_device, sign_up_data_device[%_days_with_traffic]) RETURN SWITCH ( TRUE(), TrafficPercentage = 0, "0%", TrafficPercentage <= 0.25, ">0 -25%", TrafficPercentage <= 0.5, ">25 -50%", TrafficPercentage <= 0.75, ">50 -75%", TrafficPercentage > 0.75, ">75-100%", "0%" )



1 ACCEPTED SOLUTION

Hi, if the measure is needed, please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1710795496984.png

 

 

Category % measure = 
IF (
    HASONEVALUE ( data[id] ),
    SWITCH (
        TRUE (),
        SUM ( data[value] ) = 0, "0%",
        SUM ( data[value] ) <= 0.25, ">0 -25%",
        SUM ( data[value] ) <= 0.5, ">25 -50%",
        SUM ( data[value] ) <= 0.75, ">50 -75%",
        SUM ( data[value] ) <= 1, ">75-100%"
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1710785609032.png

 

SWITCH function (DAX) - DAX | Microsoft Learn

 

 

Category % CC =
SWITCH (
    TRUE (),
    data[value] = 0, "0%",
    data[value] <= 0.25, ">0 -25%",
    data[value] <= 0.5, ">25 -50%",
    data[value] <= 0.75, ">50 -75%",
    data[value] <= 1, ">75-100%"
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

It's a great aproximation of how my data looks like, something a I forgot to write, is that I'm working in Direct Query mode, where the creating custom column function is a litle restricted.

Hi, if the measure is needed, please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1710795496984.png

 

 

Category % measure = 
IF (
    HASONEVALUE ( data[id] ),
    SWITCH (
        TRUE (),
        SUM ( data[value] ) = 0, "0%",
        SUM ( data[value] ) <= 0.25, ">0 -25%",
        SUM ( data[value] ) <= 0.5, ">25 -50%",
        SUM ( data[value] ) <= 0.75, ">50 -75%",
        SUM ( data[value] ) <= 1, ">75-100%"
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.