Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi All,
This is a calculated column in Sheet (Mails) that returns 1 if someone in Sheet (Test) submitted twice (by distinct-counting the submitted on dates), 0.5, if someone submitted once, and 0 if someone didn't submitt at all.
Solved! Go to Solution.
Hi @NaderSaeed ,
If you want to use date slicer to control the result, you need to create a measure not a calculate column.
We create a measure based on your business logic to meet your requirement.
1. We need to create a relationship between Mail table and Test table.
2. Then we can create a measure.
Measure =
VAR M =
MAX ( Mail[Mails] )
VAR _selected_Start =
SELECTEDVALUE ( 'Start Date'[Value] )
VAR _selected_End =
SELECTEDVALUE ( 'End Date'[Value] )
VAR _result1 =
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER (
ALLSELECTED ( Test ),
Test[Submittedby] = M
&& Test[SubmittedOn] >= _selected_Start
&& Test[SubmittedOn] <= _selected_End
)
) >= 2,
1,
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER (
ALLSELECTED ( Test ),
Test[Submittedby] = M
&& Test[SubmittedOn] >= _selected_Start
&& Test[SubmittedOn] <= _selected_End
)
) = 1,
0.5,
0
)
)
VAR _result2 =
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER ( ALLSELECTED ( Test ), Test[Submittedby] = M )
) >= 2,
1,
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER ( ALLSELECTED ( Test ), Test[Submittedby] = M )
) = 1,
0.5,
0
)
)
RETURN
IF (
ISBLANK ( _selected_Start ) || ISBLANK ( _selected_End ),
_result2,
_result1
)
3. At last we create two slicers based on Start Date and End Date.
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @NaderSaeed ,
If you want to use date slicer to control the result, you need to create a measure not a calculate column.
We create a measure based on your business logic to meet your requirement.
1. We need to create a relationship between Mail table and Test table.
2. Then we can create a measure.
Measure =
VAR M =
MAX ( Mail[Mails] )
VAR _selected_Start =
SELECTEDVALUE ( 'Start Date'[Value] )
VAR _selected_End =
SELECTEDVALUE ( 'End Date'[Value] )
VAR _result1 =
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER (
ALLSELECTED ( Test ),
Test[Submittedby] = M
&& Test[SubmittedOn] >= _selected_Start
&& Test[SubmittedOn] <= _selected_End
)
) >= 2,
1,
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER (
ALLSELECTED ( Test ),
Test[Submittedby] = M
&& Test[SubmittedOn] >= _selected_Start
&& Test[SubmittedOn] <= _selected_End
)
) = 1,
0.5,
0
)
)
VAR _result2 =
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER ( ALLSELECTED ( Test ), Test[Submittedby] = M )
) >= 2,
1,
IF (
CALCULATE (
DISTINCTCOUNT ( Test[SubmittedOn] ),
FILTER ( ALLSELECTED ( Test ), Test[Submittedby] = M )
) = 1,
0.5,
0
)
)
RETURN
IF (
ISBLANK ( _selected_Start ) || ISBLANK ( _selected_End ),
_result2,
_result1
)
3. At last we create two slicers based on Start Date and End Date.
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Genius, Thanks.
@NaderSaeed ,Can you share sample data and sample output in table format?
Sheet(Test)
Sheet (Mail)
The Sheet (Mail) has all the databbase for all emails, and the Sheet (Test) only has the ones who have submitted, so I'm distinct-counting the SubmittedOn Coulmn as it'd be the best indicator in our case.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
152 | |
120 | |
102 | |
87 | |
68 |