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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Meghbajaj
Frequent Visitor

Need Help with a Measure

Overview:
I have a date based table in which I have the following columns:
ID, Date (from today's date to historical date) (ex. March 21 2023, March 20 2023, March 19 2023 etc),  Plan Type and Amount.

I am using the following formula:

Measure 6 =
CALCULATE(SUM('Worker Compensation Detail All'[PAY RATE_]),
FILTER('Worker Compensation Detail All','Worker Compensation Detail All'[Date Key] = max('Worker Compensation Detail All'[Date Key])),ALL('Worker Compensation Detail All'[PLAN TYPE]))

The sum I am getting at the bottom is correct. However, I need the column of 'Measure 6'. I guess it has something to do with the Filter context of Plan Type. 

Meghbajaj_1-1679440167659.png

I need help fixing my measure to get the required result. Thank you in advance.


 

3 REPLIES 3
igrandey89
Advocate II
Advocate II

Try replacing the [Date Key] with whatever ID column you're using in the date table, or the field used in the relationship between the two tables.

igrandey89
Advocate II
Advocate II

Potential issue with the 'Measure 6' formula is related to the filter context of the 'Plan Type' column. When you use the ALL function on the 'Plan Type' column, it removes the filter context of that column, which is causing the same value to appear in every row of the 'Measure 6' column.

To fix this issue, you can use the VALUES function to get a table of distinct values in the 'Plan Type' column and iterate over them using the SUMX function. Here is an updated formula that should work:

Measure 6 =
SUMX (
    VALUES ( 'Worker Compensation Detail All'[PLAN TYPE] ),
    CALCULATE (
        SUM ( 'Worker Compensation Detail All'[PAY RATE_] ),
        FILTER (
            ALL ( 'Worker Compensation Detail All'[PLAN TYPE] ),
            'Worker Compensation Detail All'[Date Key] = MAX ( 'Worker Compensation Detail All'[Date Key] )
        )
    )
)

I hope I am understanding your issue correctly and hope this helps

 

Hi @igrandey89 , thanks for replying back. I am still having some trouble:

Meghbajaj_0-1679469992664.png


 

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.