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

Calculate Sum if / filters based on 2 tables / dax

Hello! I have some measure creating experience but am slightly stumped because my data is in two different tables

 

Here are my two tables 

 

PGID Table

PGID Cat, Time Type

Vacation, Non-working

Business Development, Working

Bereavement, Non-working

 

AX Table

PGID Cat, Hours

Bereavement, 10

Vacation, 5

Vacation, 2

Business Development, 15

 

I would like to create a measure for Working Hours = sum of hours if PGID Cat Table time type is "working".

 

Does that make sense? I will also make one for non-working hours too of course 🙂 

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

Hi @Anonymous ,

 

Based on your description, you can do some steps as follows.

  • Solution 1:
  1. Create a measure.

_sum=sumx(‘AX’,[Hours])

  1. Create a table visual with “PGID Cat” and “_sum” field.

v-yuaj-msft_0-1605510096251.png

 

  1. Drag the “Time Type” field to the filter on this visual.
    v-yuaj-msft_1-1605510096254.png

     

  2. Select “Working” or “Non_working”.

Result:

v-yuaj-msft_0-1605510212239.png

 

 

 

  • Solution 2:
  1. Create a measure.

 

Working = IF(

    MIN('PGID'[ Time Type])="Working",

    SUMX(AX,'AX'[ Hours]))

 

Non_working = IF(MAX('PGID'[ Time Type])="Non-working",SUM('AX'[ Hours]))

Result:

v-yuaj-msft_1-1605510228915.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

2 REPLIES 2
v-yuaj-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, you can do some steps as follows.

  • Solution 1:
  1. Create a measure.

_sum=sumx(‘AX’,[Hours])

  1. Create a table visual with “PGID Cat” and “_sum” field.

v-yuaj-msft_0-1605510096251.png

 

  1. Drag the “Time Type” field to the filter on this visual.
    v-yuaj-msft_1-1605510096254.png

     

  2. Select “Working” or “Non_working”.

Result:

v-yuaj-msft_0-1605510212239.png

 

 

 

  • Solution 2:
  1. Create a measure.

 

Working = IF(

    MIN('PGID'[ Time Type])="Working",

    SUMX(AX,'AX'[ Hours]))

 

Non_working = IF(MAX('PGID'[ Time Type])="Non-working",SUM('AX'[ Hours]))

Result:

v-yuaj-msft_1-1605510228915.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

DataInsights
Super User
Super User

@Anonymous,

 

Try these measures. A relationship between the tables is required.

 

Working Hours = 
CALCULATE ( SUM ( 'AX Table'[Hours] ), 'PGID Table'[Time Type] = "Working" )

Non-working Hours = 
CALCULATE ( SUM ( 'AX Table'[Hours] ), 'PGID Table'[Time Type] = "Non-working" )

 

DataInsights_0-1605459338621.png

 

DataInsights_1-1605459350430.png

 

 

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.