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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
patri0t82
Post Patron
Post Patron

Using a Custom Table to Tidy Things Up - Filter by Date

Hello, I'm building a complex report that contains many, many measures. I was going to display all these measures in little boxes, and try to align the boxes to make it look aesthetically pleasing. This is proving to be quite difficult. I would like to instead place all my measures in a table and then use a formatted table visualization to display the results.

 

The problem is, when I build the table, my date slicers have no effect on the results. The measures individually work correctly, so I'm hoping to find a way to tie it to the calendar. Here is the custom Table formula (so far). I've included a couple images to show how the report currently looks also.

 

The bottom line, I guess, is there a better option for me, or any way to take into account the CalendarTable?

 

 

Table = 
VAR _MEASURENAME = { "LTIR", "LTIR Incidents", "RIF", "RIF Incidents" }
VAR _ADDCOLUMN =
    ADDCOLUMNS (
        _MEASURENAME,
        "This Month",
            SWITCH (
                [Value],
                "LTIR", [HSE - TM LTIR],
                "LTIR Incidents", [HSE - TM Lost Time Count],
                "RIF", [HSE - TM RIF],
                "RIF Incidents", [HSE - TM Recordable Injury Count]
            ),
        "This Quarter",
            SWITCH (
                [Value],
                "LTIR", 'Calculations - HSE'[HSE - TQ LTIR],
                "LTIR Incidents", [HSE - TQ Lost Time Count],
                "RIF", [HSE - TQ RIF],
                "RIF Incidents", [HSE - TQ Recordable Injury Count]
            )            
    )
RETURN
    _ADDCOLUMN

 

 

design.pngdesign2.png

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@patri0t82,

 

I would create a calculation group with two calculation items: This Month, and This Quarter. The concept is to define base measures and then each calculation item will calculate the measure in the specified context (this month, this quarter, etc.) This will reduce the number of measures in your model. See the article below for details.

 

https://www.sqlbi.com/articles/introducing-calculation-groups/ 

 

You can create a metric table with one row per metric, and (optionally) a sort column so you can control the sorting in a visual. Use this metric table in your visual. Then, create a measure that uses SELECTEDVALUE to get the metric for each visual row, and return the corresponding measure.





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

Proud to be a Super User!




View solution in original post

16 REPLIES 16
DataInsights
Super User
Super User

@patri0t82,

 

I would create a calculation group with two calculation items: This Month, and This Quarter. The concept is to define base measures and then each calculation item will calculate the measure in the specified context (this month, this quarter, etc.) This will reduce the number of measures in your model. See the article below for details.

 

https://www.sqlbi.com/articles/introducing-calculation-groups/ 

 

You can create a metric table with one row per metric, and (optionally) a sort column so you can control the sorting in a visual. Use this metric table in your visual. Then, create a measure that uses SELECTEDVALUE to get the metric for each visual row, and return the corresponding measure.





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

Proud to be a Super User!




Thank you for the reply - I'm sorry for the delay in responding. I understand (I think) what you're getting at, and appreciate you providing the link. Do I need to install or utilize a third party application like Tabular Editor, or is this just a change in thinking in the way I build measures?

@patri0t82,

 

You need to install Tabular Editor to create calculation groups. There's a free version (2.x) and a paid version. Once you install it, open your pbix, go to External Tools, and select Tabular Editor. Here's the download link:

 

https://tabulareditor.com/downloads 

 

Let me know how it goes.





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

Proud to be a Super User!




Thank you again. I've installed Tablular Editor and created a few Time Intelligence measures, per the link you provided. I can definitely see some benefits from calculated groups. I'm still, however having difficulty, and maybe you can tell me where I'm going wrong. 

 

I created measures for the time periods I would like to see (YTD, YTD-LY, TM, TM-LY, QTD, QTD-LY)

Screenshot 2022-10-11 132504.png

I've also created a simple measure to count Lost Time injuries:

 

HSE - Lost Time Count = 
CALCULATE (
    COUNT ( 'Recordable Injuries and Events'[Recordable Injury] ),
    'Recordable Injuries and Events'[Recordable Injury] = "Lost Time",
    'Recordable Injuries and Events'[Recordable Injury] = "Fatality"
)

 

 

When I place my Time Intelligence metrics in the column of a matrix, I see this:

Screenshot 2022-10-11 132158.png

I am unable to use my Lost Time count for the Rows. (in my previous posts, this would be LTIR Incidents).

 

Simply, it seems like my Lost Time measure is not tied to the Calendar table, or associated with my Time Intelligence measures.

 

@patri0t82,

 

Does the Calendar table have a relationship with the Recordable Injuries and Events table? This is necessary for date calculations. Be sure to mark the Calendar table as a date table.





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

Proud to be a Super User!




Thanks for the response. CalendarTable was not in fact set as the Date table. I did change it though, and yet I haven't seen a change. I did try changing the direction to both, as well, with no luck.

Screenshot 2022-10-11 150823.pngScreenshot 2022-10-11 150921.png

@patri0t82,

 

Do you have a date slicer or filter for your visual?





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

Proud to be a Super User!




Before I made the Mark as Calendar Table change, I was using a separate slicer for Month Name and another for Year. Will those no longer work if I mark as Calendar Table?

Marking the Calendar table as a date table won't affect the slicers. Try using a slicer for Date instead and see if that works. Can you share your sanitized pbix via one of the file services like OneDrive?





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

Proud to be a Super User!




Hi, I'm afraid even wide open with no date selected it's showing all zeros. I understand if there's not much more you can do without seeing something. I appreciate you getting me this far!

@patri0t82,

 

Just to confirm, do you have the Lost Time measure in the Values field well of the matrix? Since your YTD calculation item ends with "+ 0", it will display 0 if the result is blank.





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

Proud to be a Super User!




Hi, yes that's correct. I'm sorry this has been confusing. I've tried to capture everything in one screenshot for you.Screenshot 2022-10-12 105144.png

@patri0t82,

 

I think the issue is with your measure. Filter arguments are combined (intersected), so you need to write it like this if you want to use OR instead of AND:

 

HSE - Lost Time Count =
CALCULATE (
    COUNT ( 'Recordable Injuries and Events'[Recordable Injury] ),
    'Recordable Injuries and Events'[Recordable Injury]
        IN { "Lost Time", "Fatality" }
)

 





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

Proud to be a Super User!




Hey, that worked! The numbers are appearing properly now. 

With that said, back to my original post, I had may rows, 

LTIR

LTIR Incidents

RIF

RIF Incidents

etc.

 

If I use my HSE - Lost Time Count measure in the values field the numbers appear correctly, however I only want the first (second) row to show as LTIR Incidents. Any idea what I would need to do to populate the Rows?

Excellent! You can add all measures to the Values field well, and enable the setting "Switch values to rows":

 

DataInsights_0-1665587557895.png

 





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

Proud to be a Super User!




You sir, have gone above and beyond. Thank you again.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors