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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
hrafnkel11
Helper I
Helper I

Matrix Grouping Using What If Parameter

Hi – I have some calculations that previously took place in SQL that I have to move to Power BI using a What If parameter. Since we can’t use What If parameters within calculated columns, I’m at a loss on how to put it all together within a measure.

 

I basically have a list of customers that I need to group by “Buying” vs. “Not Buying” based on the value of the user-defined parameter, which sets the threshold for the # of days since last purchase. The output for this only needs to go into one matrix that looks like the below (Active/Inactive is pre-calculated in the same table and won’t change).

 

hrafnkel11_0-1646142990661.png

 

Sample data:

CustomerID

Amount

LastOrder_Days

Current_Status

217459

100

-50

Active

217467

500

-38

Inactive

217468

100

-64

Active

217476

1,000

-170

Inactive

217479

1,000

-152

Active

217481

50

-353

Inactive

 

Parameter and expected output based on parameter:

hrafnkel11_1-1646143070801.png

hrafnkel11_2-1646143077450.png

 

I get the expected result for “Buying” using the below, but it’s only the value with no label and doesn’t include the calculation for “Not Buying”. I've attempted to use SWITCH(TRUE()) and SUMMARIZE, but can't seem to get it to work. Any help would be great. Thanks!

CALCULATE(

    SUM(CUSTOMER[Amount]),

    FILTER(ALL(

        CUSTOMER[LastOrder_Days]),

        CUSTOMER[LastOrder_Days]>='BUYING STATUS THRESHOLD'[BUYING STATUS THRESHOLD Value]

        )

    )

3 REPLIES 3
amitchandak
Super User
Super User

@hrafnkel11 , You need to create an independent table(Option) with two values Buying and non buying

 

measures

 

Buy 1= CALCULATE(
SUM(CUSTOMER[Amount]),
FILTER(ALL(
CUSTOMER[LastOrder_Days]),
CUSTOMER[LastOrder_Days]>='BUYING STATUS THRESHOLD'[BUYING STATUS THRESHOLD Value]
)
)


Status = if(isblank([measure]), "Buying", "Non Buying")

 

then a measure like

 

sumx(filter(values(CUSTOMER[Customer ID]), [Status] = max(Option[Option] )), CALCULATE(
SUM(CUSTOMER[Amount]) ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you so much. Just in case anyone comes across this in the future, I needed to make one small adjustment in the Status measure (switching Buying and Not Buying), but this was the perfect solution. Thanks again!

Syk
Resident Rockstar
Resident Rockstar

What I'm understanding is you need to group your data by "Buying" and "Not Buying"..
Give this video a watch and see if it helps!
https://www.youtube.com/watch?v=D1LO8syugMA

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.