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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
powerbiexpert22
Post Patron
Post Patron

grouping labels on x axis

is it possible to show group lables on x axis like below highlighted 

 

powerbiexpert22_0-1716433229209.png

 

1 ACCEPTED SOLUTION
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.

In calendar_dimension table, I tried to create Group Quarter-Year calculated column and Group Quarter-Year sort calculated column.

 

Jihwan_Kim_1-1716435200009.png

 

 

Jihwan_Kim_0-1716435135549.png

 

Group Quarter-Year = 
VAR _today =
    TODAY ()
VAR _indexquarteryear =
    ROWNUMBER (
        VALUES ( calendar_dim[End of Quarter] ),
        ORDERBY ( calendar_dim[End of Quarter], ASC )
    )
VAR _todayindex =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                calendar_dim,
                "@indexquarteryear",
                    ROWNUMBER (
                        VALUES ( calendar_dim[End of Quarter] ),
                        ORDERBY ( calendar_dim[End of Quarter], ASC )
                    )
            ),
            calendar_dim[date] = _today
        ),
        [@indexquarteryear]
    )
RETURN
    SWITCH (
        TRUE (),
        _indexquarteryear <= _todayindex
            && _indexquarteryear >= _todayindex - 2, "Current Engagement",
        _indexquarteryear <= _todayindex - 3
            && _indexquarteryear >= _todayindex - 5, "Initial Interactions",
        _indexquarteryear <= _todayindex - 6, "Purchased",
        _indexquarteryear > _todayindex, "Future ML prediction",
        "Check again"
    )

 

 

Group Quarter-Year sort = 
VAR _today =
    TODAY ()
VAR _indexquarteryear =
    ROWNUMBER (
        VALUES ( calendar_dim[End of Quarter] ),
        ORDERBY ( calendar_dim[End of Quarter], ASC )
    )
VAR _todayindex =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                calendar_dim,
                "@indexquarteryear",
                    ROWNUMBER (
                        VALUES ( calendar_dim[End of Quarter] ),
                        ORDERBY ( calendar_dim[End of Quarter], ASC )
                    )
            ),
            calendar_dim[date] = _today
        ),
        [@indexquarteryear]
    )
RETURN
    SWITCH (
        TRUE (),
        _indexquarteryear <= _todayindex
            && _indexquarteryear >= _todayindex - 2, 0,
        _indexquarteryear <= _todayindex - 3
            && _indexquarteryear >= _todayindex - 5, -1,
        _indexquarteryear <= _todayindex - 6, -2,
        _indexquarteryear > _todayindex, 1,
        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.


Go to 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.

In calendar_dimension table, I tried to create Group Quarter-Year calculated column and Group Quarter-Year sort calculated column.

 

Jihwan_Kim_1-1716435200009.png

 

 

Jihwan_Kim_0-1716435135549.png

 

Group Quarter-Year = 
VAR _today =
    TODAY ()
VAR _indexquarteryear =
    ROWNUMBER (
        VALUES ( calendar_dim[End of Quarter] ),
        ORDERBY ( calendar_dim[End of Quarter], ASC )
    )
VAR _todayindex =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                calendar_dim,
                "@indexquarteryear",
                    ROWNUMBER (
                        VALUES ( calendar_dim[End of Quarter] ),
                        ORDERBY ( calendar_dim[End of Quarter], ASC )
                    )
            ),
            calendar_dim[date] = _today
        ),
        [@indexquarteryear]
    )
RETURN
    SWITCH (
        TRUE (),
        _indexquarteryear <= _todayindex
            && _indexquarteryear >= _todayindex - 2, "Current Engagement",
        _indexquarteryear <= _todayindex - 3
            && _indexquarteryear >= _todayindex - 5, "Initial Interactions",
        _indexquarteryear <= _todayindex - 6, "Purchased",
        _indexquarteryear > _todayindex, "Future ML prediction",
        "Check again"
    )

 

 

Group Quarter-Year sort = 
VAR _today =
    TODAY ()
VAR _indexquarteryear =
    ROWNUMBER (
        VALUES ( calendar_dim[End of Quarter] ),
        ORDERBY ( calendar_dim[End of Quarter], ASC )
    )
VAR _todayindex =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                calendar_dim,
                "@indexquarteryear",
                    ROWNUMBER (
                        VALUES ( calendar_dim[End of Quarter] ),
                        ORDERBY ( calendar_dim[End of Quarter], ASC )
                    )
            ),
            calendar_dim[date] = _today
        ),
        [@indexquarteryear]
    )
RETURN
    SWITCH (
        TRUE (),
        _indexquarteryear <= _todayindex
            && _indexquarteryear >= _todayindex - 2, 0,
        _indexquarteryear <= _todayindex - 3
            && _indexquarteryear >= _todayindex - 5, -1,
        _indexquarteryear <= _todayindex - 6, -2,
        _indexquarteryear > _todayindex, 1,
        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.


Go to My LinkedIn Page


danextian
Super User
Super User

Hi @powerbiexpert22 ,

 

In what way do you want the label to grouped? For example, for initial purchase which has two quarters, there is just a single label?










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian , sorry i should not use the word group however this is what i wanted to acheive

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.