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

Status rows = (ex) Approved, Approved, Rejected, Approved -------> Measure Returns "Rejected"

Hello BI Community, thanks in advance.

 

I'm working with two columns, ID and Status. As you can see below, the ID column may have duplicate ID #s. For a given ID, it will have a status of either "Approved" or "Rejected" (or null), but the challenge to write in DAX is to be able to identify ANY instance of a "Rejected" status for a given ID. For example, if there are 10 rows where ID= 50, 8 are "Accepted," 1 is null, and 1 is "Rejected," I need to return "Rejected."

maibacherstr_1-1637766686984.png

I don't do this very often. Can anyone please help? Thanks again,

Dan

 

1 ACCEPTED SOLUTION

@maibacherstr 

Measure 2 = 
IF (
    CALCULATE (
        CALCULATE ( COUNT ( 'Approval Table'[Status] ), 'Approval Table'[Status] = "Rejected" ),
        ALL('Package Table'),VALUES('Package Table'[PackageID])
    ) >= 1,
    "Rejected",
    "Approved"
)
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

View solution in original post

7 REPLIES 7
maibacherstr
Helper III
Helper III

Yes I did, thank you very much for your reply. The solution isn't completely integrated yet though. On first attempt I can get the measure working, but with an error that I think is based on a table relationship as follows:

 

We've been working with my "approve/reject" table which is a many-to-one relationship with my "packages" table. (The rule I'm working with is that each package goes through an approval process and if any of the approvers rejects the package, then the "packages" table will reflect it).

 

One first attempt, dropping the new measure into my Packages table visual results in every row showing "rejected." On the other hand, dropping the new measure into a "reject/approve" table visual works like a charm.

 

Dropping related fields into a table visual has always been thorny to me. Seeing your expertise so far I'd love to hear any more of your thoughts. Thanks again,

 

Dan

@maibacherstr  you did not fully mention in the original psit about the data model. I thought everything was coming from the same table.

Can you please post the sample pbix and show the desired output?

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

Hello @smpa01 , thanks again. I modified the pbix that you posted, built the data model, and added a Details tab showing the same as the graphic below. To restate the goal (as shown in the gray box in the graphic):

 

GOAL is to drop the Measure into the PackageTable and produce the result shown in the "Should Show As" column

(As shown in this example, the PackageTable.Status column is a manual entry)

RECAP: 1st attempt resulted in all "Measure" rows showing as "Rejected"

maibacherstr_2-1637942653733.png

 

Side note but I'm trying to attach a pbix to the community thread for the first time and am surprised this interface isn't making it easy at all, I'm not sure the best method but I think this should work.

 

Thanks again

@maibacherstr 

Measure 2 = 
IF (
    CALCULATE (
        CALCULATE ( COUNT ( 'Approval Table'[Status] ), 'Approval Table'[Status] = "Rejected" ),
        ALL('Package Table'),VALUES('Package Table'[PackageID])
    ) >= 1,
    "Rejected",
    "Approved"
)
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

It worked perfectly! So the difference at the end came down to the "all" vs "allexcept" functions by the look of it.

 

You are amazing and I hope you have a wonderful day.

 

Dan

smpa01
Super User
Super User

@maibacherstr  you can write a measure like this

Measure =
IF (
    CALCULATE (
        CALCULATE ( COUNT ( 'Table'[Status] ), 'Table'[Status] = "Rejected" ),
        ALLEXCEPT ( 'Table', 'Table'[ID] )
    ) >= 1,
    "Rejected",
    "Accepted"
)

 

smpa01_0-1637767861472.png

pbix is atatched

 

 

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

@maibacherstr  did you have a chance to look into the solution I provided?

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