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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
poko
Resolver I
Resolver I

Help with calculated measures in a table

Hello,

I'm still quiet a new in the Power Bi and need calculated measures for particular year(2022 and 2023) for a table below. 

poko_0-1733304806089.png

any help counts Thank you.

1 ACCEPTED SOLUTION
FarhanJeelani
Super User
Super User

Hi @poko,

To create calculated measures in Power BI for the years 2022 and 2023, you would need to:

  1. Define a Year Filter: Use the year values (2022 and 2023) as filters in your DAX measures.
  2. Aggregate Based on Categories: Separate the calculations for <2 years, 2-5 years, and >5 years for both "Enhanced Supervision" and "Standard Supervision."

Here’s how you can create calculated measures step by step:

Example DAX Measures for 2022 and 2023

Assuming you have a column named Year, SupervisionType (Enhanced or Standard), DurationCategory (<2 years, 2-5 years, >5 years), and Count:

Measure for <2 Years - Enhanced Supervision (2022)

Enhanced_2022_LessThan2Years = 
CALCULATE(
    SUM(Table[Count]),
    Table[Year] = 2022,
    Table[SupervisionType] = "Enhanced Supervision",
    Table[DurationCategory] = "<2 years"
)

Measure for 2-5 Years - Enhanced Supervision (2023)

Enhanced_2023_2to5Years = 
CALCULATE(
    SUM(Table[Count]),
    Table[Year] = 2023,
    Table[SupervisionType] = "Enhanced Supervision",
    Table[DurationCategory] = "2-5 years"
)

Measure for >5 Years - Standard Supervision (2022)

Standard_2022_GreaterThan5Years = 
CALCULATE(
    SUM(Table[Count]),
    Table[Year] = 2022,
    Table[SupervisionType] = "Standard Supervision",
    Table[DurationCategory] = ">5 years"
)

Dynamic Measure for Any Combination

If you want to dynamically calculate values based on slicers for Year, SupervisionType, and DurationCategory:

DynamicMeasure = 
CALCULATE(
    SUM(Table[Count]),
    ALLSELECTED(Table[Year]),
    ALLSELECTED(Table[SupervisionType]),
    ALLSELECTED(Table[DurationCategory])
)

Steps to Implement in Power BI:

  1. Go to the "Modeling" tab in Power BI Desktop.
  2. Select "New Measure" and copy-paste the relevant DAX formula.
  3. Use the measures in a table or matrix visualization, with State as rows and Year/categories as columns.

If your data model or column names differ, share more details so I can tailor the measures to your data.

 

Please mark this as solution if it helps. Appreciate Kudos.

View solution in original post

5 REPLIES 5
v-yaningy-msft
Community Support
Community Support

Hi, @poko 

Thanks for the reply from FarhanJeelani and Thejeswar. As FarhanJeelani said, what are you currently trying to achieve and giving the results you want will help you achieve what you need faster.

Best Regards,
Yang

Community Support Team

FarhanJeelani
Super User
Super User

Hi @poko,

To create calculated measures in Power BI for the years 2022 and 2023, you would need to:

  1. Define a Year Filter: Use the year values (2022 and 2023) as filters in your DAX measures.
  2. Aggregate Based on Categories: Separate the calculations for <2 years, 2-5 years, and >5 years for both "Enhanced Supervision" and "Standard Supervision."

Here’s how you can create calculated measures step by step:

Example DAX Measures for 2022 and 2023

Assuming you have a column named Year, SupervisionType (Enhanced or Standard), DurationCategory (<2 years, 2-5 years, >5 years), and Count:

Measure for <2 Years - Enhanced Supervision (2022)

Enhanced_2022_LessThan2Years = 
CALCULATE(
    SUM(Table[Count]),
    Table[Year] = 2022,
    Table[SupervisionType] = "Enhanced Supervision",
    Table[DurationCategory] = "<2 years"
)

Measure for 2-5 Years - Enhanced Supervision (2023)

Enhanced_2023_2to5Years = 
CALCULATE(
    SUM(Table[Count]),
    Table[Year] = 2023,
    Table[SupervisionType] = "Enhanced Supervision",
    Table[DurationCategory] = "2-5 years"
)

Measure for >5 Years - Standard Supervision (2022)

Standard_2022_GreaterThan5Years = 
CALCULATE(
    SUM(Table[Count]),
    Table[Year] = 2022,
    Table[SupervisionType] = "Standard Supervision",
    Table[DurationCategory] = ">5 years"
)

Dynamic Measure for Any Combination

If you want to dynamically calculate values based on slicers for Year, SupervisionType, and DurationCategory:

DynamicMeasure = 
CALCULATE(
    SUM(Table[Count]),
    ALLSELECTED(Table[Year]),
    ALLSELECTED(Table[SupervisionType]),
    ALLSELECTED(Table[DurationCategory])
)

Steps to Implement in Power BI:

  1. Go to the "Modeling" tab in Power BI Desktop.
  2. Select "New Measure" and copy-paste the relevant DAX formula.
  3. Use the measures in a table or matrix visualization, with State as rows and Year/categories as columns.

If your data model or column names differ, share more details so I can tailor the measures to your data.

 

Please mark this as solution if it helps. Appreciate Kudos.

Hello Thank you for response I will share more details

Thejeswar
Super User
Super User

Hi @poko ,

The Details you have given might not be sufficient to answer this question. If you can share more information on this like the columns used, how is the time period present in the table, how is the supervision type refered etc.

 

In simple terms, share some sample data using which you are creating this table that you have shown in your screenshot

 

Regards,

Hello Thank you for response I will share more information with you

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.