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
venstart
Frequent Visitor

Power BI On Screen Filtered Calculation

Hi There people

 

I need need your help. So I created a power bi dashboard, below is the screenshot. I have added a date slicer so that the data will be dynamic.  I am happy with the "Opening Stock", "Sales Log" & "Harvesting Log" values (as this is coming from my data source, being sharepoint online) Below displayed in a Matrix visual

venstart.PNG

I do need help with the "Harv Minus Sales" and "Theoretical Month End Stock" value as there need to be on the fly on screen calculations without saving to get to Sharepoint, however we can use a PBI Measure.

 

For "Harv Minus Sales" = "Harvesting Log" - "Sales Log"   (example: 1140.21 - 1199.42 = -59.24 )

For "Theoretical Month End Stock" = "Opening Stock" + "Harv Minu Sales"  (example: 11.54 + -59.24  = -47.70)

 

FYI, the table name is: "Parent List"  & Field name "OData_6-6.6m19cm" for "Sales Log" & "Harvesting Log"

the table name is: "Table1" & field name "19cm to 23cm" for "Opening Stock"

 

Please could someone help will show how this is done

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @venstart ,

 

Please do like this.

For "Harv Minus Sales":

M1 = 
VAR x = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Sales Log" ), [OData_6-6.6m19cm] )
VAR y = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Harvesting Log" ), [OData_6-6.6m19cm] )
RETURN
y-x
M2 = 
VAR x = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Sales Log" ), [OData_6-6.6m25cm] )
VAR y = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Harvesting Log" ), [OData_6-6.6m25cm] )
RETURN
y-x
...

For "Theoretical Month End Stock" :

Measure = 
VAR x = 
CALCULATE(
    SUM('Parent List'[OData_6-6.6m19cm]),
    FILTER( Table1, [Column] = "Opening Stock")
)
RETURN
x + [M1]
...

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @venstart ,

 

Please do like this.

For "Harv Minus Sales":

M1 = 
VAR x = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Sales Log" ), [OData_6-6.6m19cm] )
VAR y = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Harvesting Log" ), [OData_6-6.6m19cm] )
RETURN
y-x
M2 = 
VAR x = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Sales Log" ), [OData_6-6.6m25cm] )
VAR y = SUMX( FILTER( ALLSELECTED('Parent List'), [FormMode] = "Harvesting Log" ), [OData_6-6.6m25cm] )
RETURN
y-x
...

For "Theoretical Month End Stock" :

Measure = 
VAR x = 
CALCULATE(
    SUM('Parent List'[OData_6-6.6m19cm]),
    FILTER( Table1, [Column] = "Opening Stock")
)
RETURN
x + [M1]
...

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@venstart ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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.