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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
mp390988
Post Patron
Post Patron

Calculation Groups help

Hi,

Does anyone know how I can create the below visual using calculation groups?
As you can see. the column headers has 2 tiers and needs to be exactly like this.

mp390988_0-1778017911446.png

 

I tried using calculation groups but got stuck at this point.


mp390988_1-1778018044659.pngmp390988_2-1778018109249.png


When I drill down to the lowest level of data in my matrix visual I get this which is wrong.

mp390988_0-1778018223579.png

 


Thank You






 

1 ACCEPTED SOLUTION

Your calc columns would go like this:

Group =
VAR _'Time Intelligence'[Calculation group column] = [Column]
RETURN
    SWITCH (
        TRUE (),
        _Column IN { "MTD", "QTD", "YTD" }, "",
        _Column IN { "MTD Target", "QTD Target", "YTD Target" }, " ",
        _Column IN { "£", "%" }, "MTD VAR",
        _Column IN { "£.", "% " }, "QTD VAR",
        _Column IN { "£..", "%  " }, "YTD VAR",
        _Column = "Rate", "Daily Run",
        _Column = "Rate Target", "Daily Run ",
        _Column IN { "£...", "%   " }, "MTD RR VAR"
    )


Sort =
VAR _'Time Intelligence'[Calculation group column] = [Column]
RETURN
    SWITCH (
        TRUE (),
        _Column IN { "MTD", "QTD", "YTD" }, 1,
        _Column IN { "MTD Target", "QTD Target", "YTD Target" }, 2,
        _Column IN { "£", "%" }, 3,
        _Column IN { "£.", "% " }, 4,
        _Column IN { "£..", "%  " }, 5,
        _Column = "Rate", 6,
        _Column = "Rate Target", 7,
        _Column IN { "£...", "%   " }, 8
    )

 

A custom sort column is needed so the groups follow the same order as shown in the screenshot. Notice the trailing spaces in the grouping values - these are intentional so Power BI treats them as different values, allowing them to appear as separate columns.

 

Also note the periods. Power BI does not allow multiple calculation items with identical names. A workaround is to replace the period with a zero-width space character, which can be copied from [Unicode Explorer - Zero Width Space](https://unicode-explorer.com/c/200B?utm_source=chatgpt.com).

 

Since the character is invisible, it can be difficult to work with. After replacing the periods, both calc columns will also need to be updated accordingly.

 

You should be able to view the calculation group table in data view

danextian_0-1778124508827.png

Also, the calcuation items can be edited in the model/diagram view

danextian_1-1778124545553.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"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.

View solution in original post

6 REPLIES 6
mp390988
Post Patron
Post Patron

Hi @danextian,

 

What values should the calculated column contain? My column headers have two levels and the first 6 columns the headers are on just 1 level.

 

Thank You,

M

Your calc columns would go like this:

Group =
VAR _'Time Intelligence'[Calculation group column] = [Column]
RETURN
    SWITCH (
        TRUE (),
        _Column IN { "MTD", "QTD", "YTD" }, "",
        _Column IN { "MTD Target", "QTD Target", "YTD Target" }, " ",
        _Column IN { "£", "%" }, "MTD VAR",
        _Column IN { "£.", "% " }, "QTD VAR",
        _Column IN { "£..", "%  " }, "YTD VAR",
        _Column = "Rate", "Daily Run",
        _Column = "Rate Target", "Daily Run ",
        _Column IN { "£...", "%   " }, "MTD RR VAR"
    )


Sort =
VAR _'Time Intelligence'[Calculation group column] = [Column]
RETURN
    SWITCH (
        TRUE (),
        _Column IN { "MTD", "QTD", "YTD" }, 1,
        _Column IN { "MTD Target", "QTD Target", "YTD Target" }, 2,
        _Column IN { "£", "%" }, 3,
        _Column IN { "£.", "% " }, 4,
        _Column IN { "£..", "%  " }, 5,
        _Column = "Rate", 6,
        _Column = "Rate Target", 7,
        _Column IN { "£...", "%   " }, 8
    )

 

A custom sort column is needed so the groups follow the same order as shown in the screenshot. Notice the trailing spaces in the grouping values - these are intentional so Power BI treats them as different values, allowing them to appear as separate columns.

 

Also note the periods. Power BI does not allow multiple calculation items with identical names. A workaround is to replace the period with a zero-width space character, which can be copied from [Unicode Explorer - Zero Width Space](https://unicode-explorer.com/c/200B?utm_source=chatgpt.com).

 

Since the character is invisible, it can be difficult to work with. After replacing the periods, both calc columns will also need to be updated accordingly.

 

You should be able to view the calculation group table in data view

danextian_0-1778124508827.png

Also, the calcuation items can be edited in the model/diagram view

danextian_1-1778124545553.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"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 ,

Thank you so much for your dedicated time in explaining the solution. Much appreciated 🙂
Your explanation helped me achieve what I wated.

mp390988_0-1778162267842.png


Thank You,
M



OwenAuger
Super User
Super User

Hi @mp390988 

If you need to have a two-level hierarchy containing your calculation items to be applied across columns, one solution is to add a calculated column to your calculation group table representing the top level of the hierarchy.

 

You would then place the top level column and the calculation item column in the Matrix visual columns.

See this blog post for an example.

 

Since your first 6 columns (MTD to YTD Target) have only a single level, you would have to have a "blank" top level for those items to create a similar appearance.

 

Would something like this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Hi @OwenAuger ,

 

Thank you for your response.


I read your post a few times to see if I can accomplish what I need here. You are right that I need a 2 level hierarchy in my column headers for my matrix and the first 6 columns only have a single level. 

But I am still confused on how to do it even after reading your post a few times and am going round and round in circles. 

I guess this is quite a specific and pretty complex task which is why I am finding it so difficult. 

Thank You,

M

Find the calculation group  column in the fields pane and then create a calculated column in the same table

danextian_0-1778108395094.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"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.

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.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.