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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
D3K
Advocate II
Advocate II

Getting value as a measure

 Hi everyone!

 

Faced as a begginer with next problem, really hope for your help!

Need to get value of Profit Margin of parent group for any distinct Product as a measure, by clicking on a product name in a table on a Desktop sheet.

 

Here is the situation.Снимок экрана (6).png

 

 

Will try to explain to be clear. I need to get Group Profit Margin for last 90 days (already calculated and made a support table) for any Product as a measure by clicking on product name, to use it in further calculations. The reason is: we already got a Cost Price for product and I want to make a next measure "Product Cost Price / (1 - it's Group Margin)" to get a Recommended Sale Price. 

 

Thank you!

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @D3K,

 

You can try this DAX formula as a measure:

Group Margin =
VAR GroupMargin =
    SELECTEDVALUE ( ClassiferTable[Group ID], BLANK () )
RETURN
    CALCULATE ( [Group Margin Measure], 'Group Margin'[Group ID] = GroupMargin )

Replace the text strings above in red with the actual group margin measure.

Considerations;

  • The measure has to be an aggregation. Power BI won't accept a column as an argument as it will return multiple values. By the looks of it, your Group Margin table already contains summarized values by Group ID. You can use MIN( 'Group Margin Table'[Group Margin] ),  MAX( 'Group Margin Table'[Group Margin] ),  SUM( 'Group Margin Table'[Group Margin] ) as long as it returns the correct group margin value.
  • The formula will return blank if selecting two or more Product ID returns more than one Group ID. SELECTEDVALUE() returns a single value if, based on the current filter context, only a single value is being returned for Product ID. If not a single value is selected, it will return blank and there is no blank Product ID.
  • It relies on the selection from Classifer table. If you selecting anyting from the Sales table and there's no relationship between Classifer and Sales table, then the measure won't work and will just return blank.




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @D3K,

 

You can try this DAX formula as a measure:

Group Margin =
VAR GroupMargin =
    SELECTEDVALUE ( ClassiferTable[Group ID], BLANK () )
RETURN
    CALCULATE ( [Group Margin Measure], 'Group Margin'[Group ID] = GroupMargin )

Replace the text strings above in red with the actual group margin measure.

Considerations;

  • The measure has to be an aggregation. Power BI won't accept a column as an argument as it will return multiple values. By the looks of it, your Group Margin table already contains summarized values by Group ID. You can use MIN( 'Group Margin Table'[Group Margin] ),  MAX( 'Group Margin Table'[Group Margin] ),  SUM( 'Group Margin Table'[Group Margin] ) as long as it returns the correct group margin value.
  • The formula will return blank if selecting two or more Product ID returns more than one Group ID. SELECTEDVALUE() returns a single value if, based on the current filter context, only a single value is being returned for Product ID. If not a single value is selected, it will return blank and there is no blank Product ID.
  • It relies on the selection from Classifer table. If you selecting anyting from the Sales table and there's no relationship between Classifer and Sales table, then the measure won't work and will just return blank.




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

danextian, thanks a lot! It works! And definately what I need Smiley Very Happy

If that is so, please accep my post as solution to change the status to thread to resolved.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors