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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bibbilibobbili
Frequent Visitor

Exhausted all my ideas

I'm lost against a problem I'm having with a data model. I think I'm going about this all wrong and need a new perspective.

 

I have an unpivoted column of "Results", in this column are results that need to be paired together to work out percentage reduction of measurable(weight, moisture) after processing. In the Results Column are results before processing and results after treatment, these are differentiated by Columns that describe the measurable, the date of processing and if the data point is before or after processing).  

 

I've found it easy to work out the mean of the % reduction, but I need to accomplish this row by row, so I can perform standard deviation on the % reduction results.

The Data looks a little something like this

DateWhenWhatResult
01/10/2021BeforeDensity50
01/10/2021BeforeWeight99
01/10/2021BeforeMoisture20
01/10/2021AfterDensity10
01/10/2021AfterWeight54
01/10/2021AfterMoisture10
02/10/2021BeforeDensity60
02/10/2021BeforeWeight91
02/10/2021BeforeMoisture30
02/10/2021AfterDensity15
02/10/2021AfterWeight5
02/10/2021AfterMoisture15
03/10/2021BeforeDensity70
03/10/2021BeforeWeight75
03/10/2021BeforeMoisture90
03/10/2021AfterDensity20
03/10/2021AfterWeight3
03/10/2021AfterMoisture10
04/10/2021BeforeDensity50
04/10/2021BeforeWeight54
04/10/2021BeforeMoisture55
04/10/2021AfterDensity10
04/10/2021AfterWeight12
04/10/2021AfterMoisture51
05/10/2021BeforeDensity40
05/10/2021BeforeWeight88
05/10/2021BeforeMoisture45
05/10/2021AfterDensity5
05/10/2021AfterWeight11
05/10/2021AfterMoisture37

 

Thanks for reading.

1 ACCEPTED SOLUTION

Hello again,

 

I managed to solve this last night. After being hit repeatedly with circular dependency errors I duplicated the query and drew in the "after" information from the 2nd query using this formula that aligned the data for me.

Column = IF('Table'[When] = "Before",
CALCULATE(FIRSTNONBLANK('Table (2)'[Result],TRUE()),
FILTER('Table (2)','Table (2)'[Date] = 'Table'[Date]),
FILTER('Table (2)','Table (2)'[What] = 'Table'[What]),
FILTER('Table','Table'[When] = "After")))

The output looked like this

bibbilibobbili_0-1637313078672.png

And now I can perform calculations on the two columns to work out % removal on a row by row basis and perform STDEV on them.
The solution feels messy to me, I feel like there should be a way to accomplish this without duplicating the query.

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Please show the expected result.  Are you looking at a calculated column solution or a measure solution?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
Community Support
Community Support

HI @bibbilibobbili,

It seems like you want to apply two calculated on your records. I'd like to suggest you create a variable table for the first calculation then add an iterator function to apply the second aggregate on the table results.

Measure Totals, The Final Word - Microsoft Power BI Community

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hello again,

 

I managed to solve this last night. After being hit repeatedly with circular dependency errors I duplicated the query and drew in the "after" information from the 2nd query using this formula that aligned the data for me.

Column = IF('Table'[When] = "Before",
CALCULATE(FIRSTNONBLANK('Table (2)'[Result],TRUE()),
FILTER('Table (2)','Table (2)'[Date] = 'Table'[Date]),
FILTER('Table (2)','Table (2)'[What] = 'Table'[What]),
FILTER('Table','Table'[When] = "After")))

The output looked like this

bibbilibobbili_0-1637313078672.png

And now I can perform calculations on the two columns to work out % removal on a row by row basis and perform STDEV on them.
The solution feels messy to me, I feel like there should be a way to accomplish this without duplicating the query.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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