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
Miaouss_1060
New Member

DAX measure based on two slicer outputs

Hello everyone!


I am trying to solve following puzzle, but fail until now, even though I spent quite some time looking for similar problems.

 

I have following table:

CustomerMonthAttribute
ArmandJanuary'active'
ArmandFebruary'active'
ArmandMarch'active'
BénédicteJanuary'inactive'
BénédicteFebruary'inactive'
BénédicteMarch'inactive'
ClaudeJanuary'active'
ClaudeFebruary'active'
ClaudeMarch'inactive'
.........

 

I also have two slicers both based on table[Month] to select a start month and an end month.

 

I try to figure out a DAX formula for a measure to get the distinct count of customers that went from attribute "active" to "inactive", based on the selected start month and selected end month. (Eventually to display this measure in a KPI card.)

E.g.: selected start month is January, selected end month is February → my measure should return 0.

E.g.: selected start month is January, selected end month is March → my measure should return 1 (only Claude was active in January and inactive in March).

 

I tried several approaches, including some involving a duplication of the table, but without success until now. I would be very greateful for your help!
Best regards.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Miaouss_1060 ,

Please try this way:
First of all I would recommend that you use a numerical form to record the month, as numbers are easier to use for calculations.
Here is my sample data:

vjunyantmsft_0-1712554322784.png

Use this DAX to create a measure:

Measure = 
VAR _start = MIN('Table'[MonthNo])
VAR _end = MAX('Table'[MonthNo])
VAR ActiveCustomersStart = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "active",
    'Table'[MonthNo] = _start
)
VAR InactiveCustomersEnd = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "inactive",
    'Table'[MonthNo] = _end,
    'Table'[Customer] IN ActiveCustomersStart
)
RETURN
COUNTROWS(InactiveCustomersEnd)

The final output is as below:

vjunyantmsft_1-1712554376392.pngvjunyantmsft_2-1712554383005.png
If you must need two slicers, I suggest you to add another two tables for slicers without any relationships:

vjunyantmsft_3-1712554634590.pngvjunyantmsft_4-1712554640668.png

vjunyantmsft_5-1712554648517.png

And change the measure into this:

Measure 2 = 
VAR _start = SELECTEDVALUE('Start'[MonthNo])
VAR _end = SELECTEDVALUE('End'[MonthNo])
VAR ActiveCustomersStart = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "active",
    'Table'[MonthNo] = _start
)
VAR InactiveCustomersEnd = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "inactive",
    'Table'[MonthNo] = _end,
    'Table'[Customer] IN ActiveCustomersStart
)
RETURN
COUNTROWS(InactiveCustomersEnd)

The final output is as below:

vjunyantmsft_6-1712554690815.pngvjunyantmsft_7-1712554698591.png



Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Miaouss_1060 ,

Please try this way:
First of all I would recommend that you use a numerical form to record the month, as numbers are easier to use for calculations.
Here is my sample data:

vjunyantmsft_0-1712554322784.png

Use this DAX to create a measure:

Measure = 
VAR _start = MIN('Table'[MonthNo])
VAR _end = MAX('Table'[MonthNo])
VAR ActiveCustomersStart = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "active",
    'Table'[MonthNo] = _start
)
VAR InactiveCustomersEnd = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "inactive",
    'Table'[MonthNo] = _end,
    'Table'[Customer] IN ActiveCustomersStart
)
RETURN
COUNTROWS(InactiveCustomersEnd)

The final output is as below:

vjunyantmsft_1-1712554376392.pngvjunyantmsft_2-1712554383005.png
If you must need two slicers, I suggest you to add another two tables for slicers without any relationships:

vjunyantmsft_3-1712554634590.pngvjunyantmsft_4-1712554640668.png

vjunyantmsft_5-1712554648517.png

And change the measure into this:

Measure 2 = 
VAR _start = SELECTEDVALUE('Start'[MonthNo])
VAR _end = SELECTEDVALUE('End'[MonthNo])
VAR ActiveCustomersStart = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "active",
    'Table'[MonthNo] = _start
)
VAR InactiveCustomersEnd = 
CALCULATETABLE(
    VALUES('Table'[Customer]),
    'Table'[Attribute] = "inactive",
    'Table'[MonthNo] = _end,
    'Table'[Customer] IN ActiveCustomersStart
)
RETURN
COUNTROWS(InactiveCustomersEnd)

The final output is as below:

vjunyantmsft_6-1712554690815.pngvjunyantmsft_7-1712554698591.png



Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello v-junyant-msft,
Your solution works perfectly! Thanks a lot! 😄
Best regards.

Miaouss_1060
New Member

Hello johnbasha33,

Thanks for the very fast reply!

Unfortunately the measure returns "empty"; except if I replace the "active" by "inactive" in the formula: in that case I get the total number of customers in my table (independently from the selected start and end months).
A precision: it is possible that a customer switches back from "inactive" to "active" (not an illustrated case in my table).
I am trying to make your formula work (no success for now); I wonder if the LASTNONBLANK() function could be the issue (I at least am not sure on how it is intended to work).
Best regards.

johnbasha33
Super User
Super User

@Miaouss_1060 

Try the below one
TransitionedCustomers =
VAR SelectedStartMonth = SELECTEDVALUE('SlicerStartMonth'[Month])
VAR SelectedEndMonth = SELECTEDVALUE('SlicerEndMonth'[Month])
RETURN
COUNTROWS(
FILTER(
VALUES('Table'[Customer]),
CALCULATE(
LASTNONBLANK('Table'[Attribute], 1),
FILTER(
ALL('Table'),
'Table'[Month] = SelectedStartMonth &&
'Table'[Customer] = 'Table'[Customer]
)
) = "active" &&
CALCULATE(
LASTNONBLANK('Table'[Attribute], 1),
FILTER(
ALL('Table'),
'Table'[Month] = SelectedEndMonth &&
'Table'[Customer] = 'Table'[Customer]
)
) = "inactive"
)
)

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!

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.