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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
jyeager
Helper I
Helper I

Filters and Measures - Guidance Needed

Hi there! Back again for more insights from all you smart people. I have a table visual where I would like to show Planned Production, Actual Production, Budgeted Hours for the production activity, and Actual Hours spent on production. Specfically, I created a measure (see DAX below) that takes total budgeted hours and total production quantities and divides the two to get a "Budget per Quantity" for production (in this case its "Budgeted Hours per Pour"). This is where my problem is.... The calcuation in the measure works but when I add it to my table visual, it adds all jobs and the budgeted hours per pour, not just the jobs that produced or were planned to produce on the dates. I added a couple screenshots below to help illustrate. 

 

Thank you in advance for your thoughts and help!

 

 

Here is the DAX for the measure I was referring to.

Budgeted Hours Per Pour = DIVIDE(CALCULATE(SUM(hours_mastertbl[Tot Budgeted Hours]),hours_mastertbl[cost_code_description]="Bed Labor"),CALCULATE(SUM(qtys_mastertbl[budgeted_qty]),qtys_mastertbl[cost_code_description]="Pours"))

 

Here is a screenshot of the table I am creating. As you can see, job D20007 is correct but the measure added a bunch of extra row with all the other active jobs. I only want to show jobs the produced in the date range I am looking at. 

 

bed_labor_hours_table_visual.PNG

Here is the data model if it helps! 

model.PNG

1 ACCEPTED SOLUTION
DataZoe
Microsoft Employee
Microsoft Employee

@jyeager 

 

I would give this a try:

Budgeted Hours Per Pour =
IF (
    ISBLANK ( [Actual Hours] ),
    BLANK (),
    SUMX (
        VALUES ( 'jobs_and_products'[Job Number] ),
        DIVIDE (
            CALCULATE (
                SUM ( hours_mastertbl[Tot Budgeted Hours] ),
                hours_mastertbl[cost_code_description] = "Bed Labor"
            ),
            CALCULATE (
                SUM ( qtys_mastertbl[budgeted_qty] ),
                qtys_mastertbl[cost_code_description] = "Pours"
            )
        )
    )
)

 

I think the issue could also be solved with CROSSFILTER in the measure too, but I usually have to play with that one a bit to get it working the way I want as I don't use it that often. https://docs.microsoft.com/en-us/dax/crossfilter-function I say that because the date filter can't get to the hours_mastertbl and qtys_mastertbl which may be why it's not able to keep the date filter correctly.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

4 REPLIES 4
DataZoe
Microsoft Employee
Microsoft Employee

@jyeager 

 

I would give this a try:

Budgeted Hours Per Pour =
IF (
    ISBLANK ( [Actual Hours] ),
    BLANK (),
    SUMX (
        VALUES ( 'jobs_and_products'[Job Number] ),
        DIVIDE (
            CALCULATE (
                SUM ( hours_mastertbl[Tot Budgeted Hours] ),
                hours_mastertbl[cost_code_description] = "Bed Labor"
            ),
            CALCULATE (
                SUM ( qtys_mastertbl[budgeted_qty] ),
                qtys_mastertbl[cost_code_description] = "Pours"
            )
        )
    )
)

 

I think the issue could also be solved with CROSSFILTER in the measure too, but I usually have to play with that one a bit to get it working the way I want as I don't use it that often. https://docs.microsoft.com/en-us/dax/crossfilter-function I say that because the date filter can't get to the hours_mastertbl and qtys_mastertbl which may be why it's not able to keep the date filter correctly.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

amitchandak
Super User
Super User

@jyeager , not very clear try

Budgeted Hours Per Pour = if(isblank([Actual Hour]), blank(),DIVIDE(CALCULATE(SUM(hours_mastertbl[Tot Budgeted Hours]),hours_mastertbl[cost_code_description]="Bed Labor"),CALCULATE(SUM(qtys_mastertbl[budgeted_qty]),qtys_mastertbl[cost_code_description]="Pours")))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
PaulDBrown
Community Champion
Community Champion

@jyeager 

It looks like you should be using an iteration function (SUMX) to iterate the calculations row by row (by date?)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Greg_Deckler
Super User
Super User

@jyeager - I don't see anything obvious in the measure like an ALL or ALLEXCEPT. Could be a missing relationship or direction of a relationship, I'll have to look closer. Any chance you can share PBIX?

 

Wait, do you just need to add some slicers to the page? How are you selecting your date range?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Users online (3,015)