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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Tiger2514555
Helper III
Helper III

SELECTEDVALU matrix total some BLANK

Tiger2514555_0-1700030087462.png

I don't understand why when there are values ​​in more than one column the values ​​are returned as BLANK, but if there are only one column the values ​​are returned correctly.

My DAX:

Week By Week =

VAR SelDemandID = SELECTEDVALUE(DemandSummaryAPS[demandID])
VAR SelItem = SELECTEDVALUE(DemandSummaryAPS[item])
VAR SelWeekDue = SELECTEDVALUE(DemandSummaryAPS[Week Num Due])

VAR FilteredTable =
    FILTER(
        'DemandSummaryAPS',
        'DemandSummaryAPS'[demandID] = SelDemandID &&
        'DemandSummaryAPS'[item] = SelItem  &&
        'DemandSummaryAPS'[Week Num Due] = SelWeekDue &&
        'DemandSummaryAPS'[demandID] <> BLANK()
    )
VAR _max_demand_id =
    MAXX(FilteredTable, 'DemandSummaryAPS'[demandID])

VAR _min_demand_id =
    MINX(FilteredTable, 'DemandSummaryAPS'[demandID])


VAR _max_week_num =
    MAXX(FilteredTable, 'DemandSummaryAPS'[Week Num Create])

VAR _min_week_num =
    MINX(FilteredTable, 'DemandSummaryAPS'[Week Num Create])

VAR MaxWeekNumCreate =
        SUMX(
            FILTER(
                FilteredTable,
                'DemandSummaryAPS'[Week Num Create] = _max_week_num
            ),
            'DemandSummaryAPS'[quantity]
        )
       
VAR MinWeekNumCreate =
        SUMX(
            FILTER(
                FilteredTable,
                'DemandSummaryAPS'[Week Num Create] = _min_week_num
            ),
            'DemandSummaryAPS'[quantity]
        )

VAR SUM_Week_By_Week =
    IF(
         _max_week_num = MAXX(FilteredTable, 'DemandSummaryAPS'[Week Num Create]) &&  _min_week_num = MAXX(FilteredTable, 'DemandSummaryAPS'[Week Num Create] - 1),
        MaxWeekNumCreate - MinWeekNumCreate,
        0
    )

RETURN
    SUM_Week_By_Week
4 REPLIES 4
vanessafvg
Community Champion
Community Champion

selectedvalue() needs filter context or it will always show blank if giving multiple values as its intended for only one value. 

 

use a different aggregation function like max or min if you are looking at multiple values, you will still  need to return one value.

 

 

https://www.sqlbi.com/articles/using-the-selectedvalue-function-in-dax/





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




But in my total there are several contexts that I think might need to be changed to a different one.

Tiger2514555_0-1700036218869.png

Because I need the difference of Week Num Create 45 and 44. with quantities which have many values ​​in case I want to see in total.
So do you have any ideas on how to fix it?

if you can provide some sample data with and example of your expected result then it will be easier to help you.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Tiger2514555_0-1700039294829.png

I have the same product but the DemandID is different. I want to compare volumes to see how much they increased or decreased using Week Num Create as a basis. Right now I'm using the most recent week and the previous week. Now I can get it to display correctly in the weekly column. But the total field is not displayed correctly. I want the correct total to be displayed.

My DAX use now:

Week By Week =

VAR FilteredTable =
    FILTER(
        'DemandSummaryAPS',
        'DemandSummaryAPS'[demandID] = 'DemandSummaryAPS'[demandID] &&
        'DemandSummaryAPS'[item] = 'DemandSummaryAPS'[item] &&
        'DemandSummaryAPS'[Week Num Due] = 'DemandSummaryAPS'[Week Num Due] &&
        'DemandSummaryAPS'[demandID] <> BLANK()
    )

VAR _max_demand_id =
    MAXX(FilteredTable, 'DemandSummaryAPS'[demandID])

VAR _min_demand_id =
    MINX(FilteredTable, 'DemandSummaryAPS'[demandID])

VAR _max_week_num =
    MAXX(FilteredTable, 'DemandSummaryAPS'[Week Num Create])

VAR _min_week_num =
    MINX(FilteredTable, 'DemandSummaryAPS'[Week Num Create])

VAR MaxWeekNumCreate =
        SUMX(
            FILTER(
                FilteredTable,
                'DemandSummaryAPS'[Week Num Create] = _max_week_num
            ),
            'DemandSummaryAPS'[quantity]
        )
       
VAR MinWeekNumCreate =
        SUMX(
            FILTER(
                FilteredTable,
                'DemandSummaryAPS'[Week Num Create] = _min_week_num
            ),
            'DemandSummaryAPS'[quantity]
        )


VAR SUM_Week_By_Week =
    IF(
        _max_demand_id = _min_demand_id,
        SUMX(
            VALUES('DemandSummaryAPS'[item]),
            MaxWeekNumCreate - MinWeekNumCreate
        ),
        0
    )


RETURN
    SUM_Week_By_Week

@vanessafvg 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Users online (2,816)