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
Amitkr174
Helper III
Helper III

Eliminate Records DAX

Hi,

I need your help in DAX. I have a scenarion that a Budget has many Milestones with different status.

I need to eliminate those budgets all together where the Milestone status is cancelled.   

Below is the table for your reference:- 

 

Budget IDMilestoneMilestone Status
BG-10001Completed
BG-10002In progress
BG-10003Canceled
BG-10004Completed
BG-10005In progress
2 ACCEPTED SOLUTIONS
Amitkr174
Helper III
Helper III

@smpa01  Desired output would be that this record (Budget id) will not appear in the report.

View solution in original post

v-yiruan-msft
Community Support
Community Support

Hi @Amitkr174 ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a measure as below to judge whether the current budget include cancelled status

Flag = 
VAR _selbuget =
    SELECTEDVALUE ( 'Table'[Budget ID] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[Budget ID] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Milestone Status] = "Canceled" )
    )
RETURN
    IF ( _selbuget IN _tab, 0, 1 )

2. Create a visual and apply a visual-level filter with condition (Flag is 1)

yingyinr_0-1638169710143.png

If the above one can't help you get the expected result, please provide more sample data with Text format and your expected result with calculation logic and special examples. Thank you.

Best Regards

Community Support Team _ Rena
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

9 REPLIES 9
v-yiruan-msft
Community Support
Community Support

Hi @Amitkr174 ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a measure as below to judge whether the current budget include cancelled status

Flag = 
VAR _selbuget =
    SELECTEDVALUE ( 'Table'[Budget ID] )
VAR _tab =
    CALCULATETABLE (
        VALUES ( 'Table'[Budget ID] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Milestone Status] = "Canceled" )
    )
RETURN
    IF ( _selbuget IN _tab, 0, 1 )

2. Create a visual and apply a visual-level filter with condition (Flag is 1)

yingyinr_0-1638169710143.png

If the above one can't help you get the expected result, please provide more sample data with Text format and your expected result with calculation logic and special examples. Thank you.

Best Regards

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

@v-yiruan-msft - This is great, this solved my purpose. Thank you very much!

Amitkr174
Helper III
Helper III

@smpa01  Desired output would be that this record (Budget id) will not appear in the report.

Hi @Amitkr174 

 

Try this Measure:

Measure = 
Var _A = CALCULATE(COUNTROWS('Table'),filter(ALLEXCEPT('Table','Table'[Budget ID]),'Table'[Milestone Status]="Canceled"))
return
iF(_A>0,BLANK(),1)

 

and add that to the filter of your visual and set the filter to shows 1.

 

Output:

VahidDM_0-1637878359038.png

 

 

If you want to add a new colum, use this code:

Column = 
Var _A = CALCULATE(COUNTROWS('Table'),filter(ALLEXCEPT('Table','Table'[Budget ID]),'Table'[Milestone Status]="Canceled"))
return
if(_A>0,BLANK(),[Milestone Status])

 

output:

VahidDM_1-1637878439685.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

VahidDM - I tried but still the Budget which has canceled Milestone is appearing, even if I set the filter to 1 budget id will that has canceled Milestone will appear.

Amitkr174_0-1637934635127.png

 

HI @Amitkr174 

 

Dis you use my codes as a measure or column? Can you share you PBIX file after removing sensetive data?

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

@VahidDM  I used it as a measure. My data is connected to direct query so even if I'll upload the power bi report, you won't be able to access the dataset 😞

@Amitkr174  achievable in two ways

_m1 = 
VAR _0 =
    ALLEXCEPT ( tbl, tbl[Budget ID] )
VAR _1 =
    SUMMARIZE (
        CALCULATETABLE ( tbl, tbl[Milestone Status] IN { "Cancelled" }, _0 ),
        tbl[Budget ID]
    )
VAR _2 =
    SUMMARIZE (
        CALCULATETABLE ( tbl, NOT tbl[Milestone Status] IN { "Cancelled" }, _0 ),
        tbl[Budget ID]
    )
VAR _3 =
    EXCEPT ( _2, _1 )
RETURN
    CALCULATE ( MAX ( tbl[Milestone Status] ), TREATAS ( _3, tbl[Budget ID] ) )

 

_m2 = 
MAXX (
    tbl,
    IF (
        ISEMPTY (
            CALCULATETABLE (
                tbl,
                tbl[Milestone Status] IN { "Cancelled" },
                ALLEXCEPT ( tbl, tbl[Budget ID] )
            )
        ),
        MAX ( tbl[Milestone Status] )
    )
)

 

smpa01_0-1637861738915.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
smpa01
Super User
Super User

@Amitkr174  what is the desire doutput for the sample above?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.

Top Solution Authors