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

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.

Reply
Anonymous
Not applicable

Dax formula measure

Hello, everyone,
I am creating a DAX measure to calculate the number for which the "START" intervention exists and for which at least one "END" intervention exists. You can see the columns below : The columns are from the same table called Table 1. according to this figure, there are a lot of data. 

 

Capture.PNG

My best regards. Thank you.

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Based on my understanding, you could create a measure like this

count for start = CALCULATE(COUNT(Sheet8[column2]),FILTER(ALLEXCEPT(Sheet8,Sheet8[column1]),Sheet8[column2]="start"))

count for end = CALCULATE(COUNT(Sheet8[column2]),FILTER(ALLEXCEPT(Sheet8,Sheet8[column1]),Sheet8[column2]="end"))

flag = IF([count for start]<>BLANK()&&[count for end]<>BLANK(),1,0)

count = COUNTX(FILTER(VALUES(Sheet8[column1]),[flag]=1),Sheet8[column1])

5.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
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
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Based on my understanding, you could create a measure like this

count for start = CALCULATE(COUNT(Sheet8[column2]),FILTER(ALLEXCEPT(Sheet8,Sheet8[column1]),Sheet8[column2]="start"))

count for end = CALCULATE(COUNT(Sheet8[column2]),FILTER(ALLEXCEPT(Sheet8,Sheet8[column1]),Sheet8[column2]="end"))

flag = IF([count for start]<>BLANK()&&[count for end]<>BLANK(),1,0)

count = COUNTX(FILTER(VALUES(Sheet8[column1]),[flag]=1),Sheet8[column1])

5.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi

 

could you please clarify? Start /end within the same Column1 value? 

So for example in this case your expected result would be 3?

 

IF SO use a calculated column with this formula

IsEndFound=

VAR thisCol1=Yourtablename['Column1']

RETURN
IF(YourTableName['Column2']="Start";
countrows(filter(yourtablename;
    yourtablename['Column1']=thisCol1 &&
    yourTableName['Column2']="End"))
;0)

This column will have a 1 for the START rows that has a corresponding END. Your result is the sum of this column.

CAREFUL: if there are MULTIPLE END with the same start you will have more than 1 in that cell!



Anonymous
Not applicable

Hi,

Sorry, I didn't mention it I would like to do a distinct count to calculate the number for which the "START" intervention exists and for which at least one "END" intervention exists.

Anonymous
Not applicable

Hi

 

then use this formula

 

IsEndFound=

VAR thisCol1=Yourtablename['Column1']

RETURN
IF(YourTableName['Column2']="Start";
countrows(filter(yourtablename;
    yourtablename['Column1']=thisCol1 &&
    yourTableName['Column2']="End"))
;BLANK())

This will return BLANK for rows where there is not corresponding END and so you can use a distinctcount

CALCULATE ( DISTINCTCOUNT ( MyTable[MyColumn] ), MyTable[MyColumn] <> BLANK () )
    + 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.