Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Row context in measures?

Hi all,

 

I have a table with 500,000 rows - it's a list of inspections undertaken against various licenses. There's not much on the table itself in the way of data - it's linked, using keys, to a number of dimension tables which hold that information, e.g.:

 

Inspection ID    dim_license_key    dim_inspection_date_key     dim_inspection_result_key    dim_inspection_type_key    
1346474272543762457657
23864235274367326465372
3224235237236742134365

 

Now I'm confused because I need to write a measure that seems quite complex to me, the "Percentage of re-inspections conducted that improved from previous score". To explain, we inspect each license multiple times. Each time we give out a score. Out of the re-inspections, i.e. the inspections involving a place we've visited before, we want to know how many involve a higher score being given than was awarded the time before.

 

I've done this sort of thing before in other contexts by writing a calculated column "Improved from previous score?" and using EARLIER/EARLIEST. But I'm not sure how to do it this time:

1. There's 500,000 rows - when I did write some calculated columns they took minutes to calculate.

2. The data is on the dim tables, not on the Inspection table itself. I need to state in the formula for example that I only want to count inspections where dim_inspection_type[Eligibility] = "Eligible" and where dim_inspection_result[Score] > dim_inspection_result[Score] (for any previous inspection).

 

It would be great to be able to do it in a measure, but as you can see, it seems to inherently involve looking row context, which doesn't seem to be compatible with (my understanding of) measures. I'm sure other people are dealing with much larger datasets and more conceptually complicated calculations than me, so I was wondering whether anyone could give me a steer on how this sort of thing is achieved in Power BI.

 

Unfortunately I can't share my data or file, but I can create some fake tables to fully illustrate what the dim tables above look like if it's not clear.

 

Cheers!

1 Reply

  • "The data is on the dim tables, not on the Inspection table itself".  If that is the case then they are not dim tables, they are fact tables.  Rethink your data model.