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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
KLibs
New Member

Using a Measure Across Fields to Calculate a flag

Context: 

I am calculating a survey average for the prior year across states, and I want to flag if a customer is in that state and gave a score lower than the state's annual average. 

 

This is what I've got right now:

StatePY Annual AvgCustomer IDCustomer Avg
AZ41234
AZ3ABC3
AZ34563
CA4DEF4
CA57895
CA3GHI3

 

So I want the PY Annual Avg to be a locked value based on just the State, but when I add the Customer ID to the table, it recalculates the measure to calculate the average for the customer, so I can't create the Y/N flag, because the PY Annual Avg column doesn't stay "locked" to the desired value. 

 

This is what I want the output to look like:

StatePY Annual Avg*DESIRED VIEW*Customer IDCustomer Avg**Desired Flag**
AZ3.331234N
AZ3.33ABC3Y
AZ3.334563Y
CA4DEF4N
CA47895N
CA4GHI3Y

 

I can't seem to use any windows functions, it gives me errors about scalar values. And I've tried using combinations of Keep/Allexcept/Remove filters but they don't produce the desired result (closest I get is that each customer ID gets duplciated across every state, which isn't accurate). 

 

I unfortunately can't share my real data, but hopefully this is enough context to get some help? 

Thanks in advance! 

3 REPLIES 3
lbendlin
Super User
Super User

but when I add the Customer ID to the table, it recalculates the measure to calculate the average for the customer,

 

That is not evident in your sample data. Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

I've edited the table - like I said in the post, it's just mock data so I'm trying to explain the issue I'm having, since I can't really show it. 

I cannot assist you if you are unable to provide sample data. I hope someone else can help you further.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.