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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
SzymonKl
Helper I
Helper I

measure

 Hi All 

 

Can you please help me create a measure please : 

Currently my stock balance ( measure [Processed Stock] for asset type [ASSET_TYPE_ID] = 128 is 1323, for asset type [ASSET_TYPE_ID] = 127 is 3965 and for asset type [ASSET_TYPE_ID] = 126 is 3600.

the balances for [ASSET_TYPE_ID] = 127 and 126 are corect( dont make any ajustments). I need to summarise these two balances and for every 9 units subtract one unit from [Processed Stock], where [ASSET_TYPE_ID] = 128.

that means 3965+3600 = 7565 /9 = 840.55 so subtract 840 from [Processed Stock] where [ASSET_TYPE_ID] = 128 

Any idea how to do this ? 

3 REPLIES 3
MFelix
Super User
Super User

Hi @SzymonKl ,

 

This is very generic however you can try something similar to this:

Stock Revised =
IF (
    SELECTEDVALUE ( 'Table'[ASSET_TYPE_ID] ) = 128,
    SUM ( 'Table'[Stock] )
        - SUMX (
            FILTER ( ALL ( 'Table' ), 'Table'[ASSET_TYPE_ID] <> 128 ),
            'Table'[Stock]
        ),
    SUM ( 'Table'[Stock] )
)

MFelix_0-1698758247561.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi Miguel

Unfortunately, this is not working. 

'Table'[Stock]

 is a measure not column, and the data is connected via direct query 

Hi @SzymonKl ,

 

If this is a measure then just replace the column by the measure:

Stock Revised =
IF (
    SELECTEDVALUE ( 'Table'[ASSET_TYPE_ID] ) = 128,
    [Stock] 
        - SUMX (
            FILTER ( ALL ( 'Table' ), 'Table'[ASSET_TYPE_ID] <> 128 ),
            [Stock]
        ),
[Stock]
)

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.