March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi everyone,
I have a problem that I hope you can help me with. I have user data tracked by events. I want the chart to filter out users who have at least one event_type=1 within a specified time period.
However, when I add this measure to a chart with the Y-axis as Month and Year, it doesn't work.
Here is the measure I wrote:
Solved! Go to Solution.
It looks to me like you are using Date from the fact table in your formula and your visual (possibly the slicer, too). This is not the correct way to do it.
I missed the original point you made about the "selected period". You will need something like this (after you fix the calendar issues). I assume what you want is for the slicer to select the period and for the formula to remove anyone with the event =1 for the slicer period, not the monthly periods in the column chart. If that's not what you want, then this formula will need to change
= CALCULATE (
COUNTROWS ( fact_event ),
FILTER ( User, CALCULATE ( MIN ( factevent[eventtype] ) > 1 ) ),
ALLSELECTED(Date)
)
it may be that you need this, but I can't be sure. You would have to test both.
= CALCULATE(CALCULATE (
COUNTROWS ( fact_event ),
FILTER ( User, CALCULATE ( MIN ( factevent[eventtype] ) > 1 ) ))
ALLSELECTED(Date)
)
also, do yourself a favour and get rid of the chart until it's working. Set up a matrix and add the same columns (month, event type). It is much easier to debug the problems if you can see the numbers.
after these changes, if you still can't sort it, post the workbook again and I will take a look. I will be at my desk in about 1 hour
I have deployed what I suggested. It appears to work to me.
I have deployed what I suggested. It appears to work to me.
Thank you so much for your help Matt.
It looks to me like you are using Date from the fact table in your formula and your visual (possibly the slicer, too). This is not the correct way to do it.
I missed the original point you made about the "selected period". You will need something like this (after you fix the calendar issues). I assume what you want is for the slicer to select the period and for the formula to remove anyone with the event =1 for the slicer period, not the monthly periods in the column chart. If that's not what you want, then this formula will need to change
= CALCULATE (
COUNTROWS ( fact_event ),
FILTER ( User, CALCULATE ( MIN ( factevent[eventtype] ) > 1 ) ),
ALLSELECTED(Date)
)
it may be that you need this, but I can't be sure. You would have to test both.
= CALCULATE(CALCULATE (
COUNTROWS ( fact_event ),
FILTER ( User, CALCULATE ( MIN ( factevent[eventtype] ) > 1 ) ))
ALLSELECTED(Date)
)
also, do yourself a favour and get rid of the chart until it's working. Set up a matrix and add the same columns (month, event type). It is much easier to debug the problems if you can see the numbers.
after these changes, if you still can't sort it, post the workbook again and I will take a look. I will be at my desk in about 1 hour
See my previous point
"You can't solve this problem (reliably) without a user table."
create a user table, then it should work.
Hi Matt,
I followed your instruction and it works. But the thing is when event_type is added to the chart as legend, the measure goes wrong (without the legend, it works perfectly)
Hi Matt,
Thank you again with very quick response.
I follow you instruction but it didnt work yet. I think it is somehow affected by month-year filter context in the chart. Could you help me take a look at my dataset?
https://drive.google.com/drive/folders/1sLpG6WckCVyl4nEjADqw3V8KukFb-sd8?usp=sharing
Hi Matt, Thank you so much for your promt response.
I dont think it works.
Here is the link to my dataset: https://drive.google.com/drive/folders/1sLpG6WckCVyl4nEjADqw3V8KukFb-sd8?usp=sharing
Thank you so much
I understand that DAX can be hard to learn. It's especially deceptive if you have a SQL background; most have to unlearn some concepts from SQL in order to become aware of the right approach in DAX.
As I understand the problem, you want a count of events, but exclude all events from users that have at least one event 1. Once you see a working solution, it's easy. "How" to think about this problem with respect to DAX is the real challenge.
You don't mention if you have a star schema. If you don't, you need to get one. You can't solve this problem (reliably) without a user table.
I don't know if this will work as I don't have any test data. If it doesn't, it should be close.
= CALCULATE (
COUNTROWS ( fact_event ),
FILTER ( User, CALCULATE ( MIN ( factevent[eventtype] ) > 1 ) )
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
15 | |
12 | |
9 | |
8 |
User | Count |
---|---|
41 | |
32 | |
29 | |
12 | |
12 |