Skip to main content

Notifications

Community site session details

Community site session details

Session Id : WNQHzjlPARS4KISUZduMAv
Power Apps - Error Handling
Answered

Dynamic Power BI Dax Expression

Like (0) ShareShare
ReportReport
Posted on 3 Apr 2025 15:15:03 by

Hi,
 
I have a measure in Power BI that I am trying to make dynamic.

I have a matrix with a field parameter called "Add Rows" in the Rows section of the matrix.
The user can select which fields are in the rows of the matrix by making selections in the slicer.
I want to make the grand total at the very bottom of the matrix correspond to the first selected value for 'Add Rows'.

Here's what I have so far:
Measure =
VAR CurrentGP = ROUND([Ext. GP%],10)
VAR PreviousGP = ROUND([Ext. GP% PY],10)
VAR Sales = ROUND([Ext. Sales],0)
VAR EQN = (CurrentGP-PreviousGP)*Sales
VAR SelectedRow = SELECTEDVALUE('Add Rows:'[View by: Fields]) // how can i make a version of this variable that returns the FIRST selected column?
Var Total = SUMX(VALUES(SelectedRow),[Ext. GP Impact Rate Archive]) // this does NOT work because VALUES will NOT take SelectedRow as an input
// Var Total = SUMX(VALUES(Region[EDMCS_LOB_DESC]),[Ext. GP Impact Rate Archive]) // here is an example of how it works when it is NOT dynamic - this works
VAR Calc=
SWITCH (
    TRUE(),
    ISINSCOPE(GPH[GPH Level1]),CALCULATE(EQN),
    ISINSCOPE(GPH[GPH Level2]), CALCULATE(EQN),
    ISINSCOPE(GPH[GPH Level3]), CALCULATE(EQN),
    ISINSCOPE(GPH[GPH Level4]), CALCULATE(EQN),
    ISINSCOPE(Manufacturer[VENDOR_NAME]), CALCULATE(EQN),
    ISINSCOPE(Linebuy[LINEBUY_ID]),CALCULATE(EQN),
    ISINSCOPE(Transactions[BUSINESS_GROUP]), CALCULATE(EQN),
    ISINSCOPE(Transactions[PE_BRAND_TYPE]), CALCULATE(EQN),
    ISINSCOPE(Region[EDMCS_LOB_DESC]), CALCULATE(EQN),
    ISINSCOPE(Region[EDMCS_REGION_NAME]), CALCULATE(EQN),
    ISINSCOPE(Linebuy[Commodity.Category1]), CALCULATE(EQN),
    ISINSCOPE(PS_Type[PS_Type]),CALCULATE(EQN),
    ISINSCOPE(Transactions[BUSINESS_GROUP]),CALCULATE(EQN),
    ISINSCOPE(Transactions[Commodity Tie Out Product Type]), CALCULATE(EQN),
    Total
)
RETURN
Calc

Thanks in advance for any help!
  • lbendlin Profile Picture
    7,785 Super User 2025 Season 1 on 04 Apr 2025 at 22:09:26
    Dynamic Power BI Dax Expression
    Maybe post in the Power BI forums?
     
    Your measure will only work inside a visual. Neither PowerApps not Power Automate know what to do with "SELECTEDVALUE"  or "ISINSCOPE".
  • Verified answer
    mmbr1606 Profile Picture
    11,765 Super User 2025 Season 1 on 04 Apr 2025 at 08:19:46
    Dynamic Power BI Dax Expression
    hey
     
     
    please post this question in the fabric community to be found here:
     
     
     
    cheers

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,518 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,756 Most Valuable Professional

Leaderboard

Featured topics

Loading started