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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Create a measure that gets the value of another measure for a specific row

I have a table thats used for reporting, and it needs to be filterable by date, salesman, etc in PowerBI / Excel

 

 ReportColumnReportValue
 Sales In US$###
 Sales in California$### 
 Sales Order Count ###

 

so I bang up a table with three rows and a calculated measure (quasi-code)

 

ReportValue = switch(ReportValue,"Sales In US",<some calc to get sales only in US>,"Sales In California",<some calc to get sales only in California>,"Sales Order Count",<some calc to get sales order count>)

 

my problem is that I need <some calc..> to not create its own filter context, because then all my slicers in PowerBI/Excel stop working. I really wish I could use some kind of tuple, or cell address, to specify these values, but it seems like my only choice is summarize/calculate/etc. 

 

To put it another way, I keep hitting the problem mentioned here...

 

http://community.powerbi.com/t5/Desktop/how-to-create-table-Summarizecolumns-keep-filter-context/m-p...

 

any ideas?

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi  @Anonymous,

 

Try this:

 

Create a disconnected calculated table in DAX (no relationship with data table)-

 

Table = 
DATATABLE (
    "Report", STRING,
    "Index", INTEGER,
    {
        { "Sales in US", 1 },
        { "Sales in California", 2 },
        { "Sales Order Count", 3 }
    }
)

Then a switching measure

 

 

 

Value =
VAR SelectedMeasure =
    MIN ( 'Table'[Index] )
RETURN
    IF (
        HASONEVALUE ( 'Table'[Report] ),
        SWITCH (
            SelectedMeasure,
            1, FORMAT ( [Sales in US], "$#,#" ),
            2, FORMAT ( [Sales in California], "$#,#" ),
            FORMAT ( [Order Count], "0,0" )
        )
    )

 





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

2 REPLIES 2
Anonymous
Not applicable

I was having problems because I was not using a totally disconnected table, my table was actually connected to the sales table and it was not giving good behavior for the measure. A totally disconnected table behaves correctly.

danextian
Super User
Super User

Hi  @Anonymous,

 

Try this:

 

Create a disconnected calculated table in DAX (no relationship with data table)-

 

Table = 
DATATABLE (
    "Report", STRING,
    "Index", INTEGER,
    {
        { "Sales in US", 1 },
        { "Sales in California", 2 },
        { "Sales Order Count", 3 }
    }
)

Then a switching measure

 

 

 

Value =
VAR SelectedMeasure =
    MIN ( 'Table'[Index] )
RETURN
    IF (
        HASONEVALUE ( 'Table'[Report] ),
        SWITCH (
            SelectedMeasure,
            1, FORMAT ( [Sales in US], "$#,#" ),
            2, FORMAT ( [Sales in California], "$#,#" ),
            FORMAT ( [Order Count], "0,0" )
        )
    )

 





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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors