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
johndha
Frequent Visitor

Get Sum of a measure in row context

Hello, 

I have a table of Assignments and a table Employees.

I want to get Howmany days in the filter are within every assignment start and end date ... to get the employee booking hours within the selected month and year only

For Example I selected Employee= Keerthi and month=March 2022 ... you can see that the column  **Demand_Days_of_task_in_period  will only count the days of this assignment that is within my date selection , so only march days are counted while feb and may are not.

The measure formula

** Demand_Days_of_task_in_period = CALCULATE(COUNTROWS('Date'),FILTER('Date','Date'[Date]>=MIN(Assignments[AssignmentStartDate])&&'Date'[Date]<=MIN(Assignments[AssignmentFinishDate])))

 

johndha_1-1653391327488.png

 

The requirement:

I want to access this measure out of row context, meaning that when I add it to a card it will sum all the rows values (6+1+1+1+2+2+2+2+1)= 18 .. but as you can see the card on the top right which is with the same measure is giving me blank, it will only give me a value when I select a specific row ...

 

I searched for it but found most ways are through creating a calculated column, while the measure here will depend on the user selection of the date

 

 

Thanks for help

 

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

Hi @johndha ,

You can create another new measure as below base on the current measure [Demand_Days_of_task_in_period] and apply the new measure onto the Card visual...

Measure =
SUMX (
    GROUPBY ( 'Assignments', 'Assignments'[Employee Name], 'Assignments'[TaskName] ),
    [Demand_Days_of_task_in_period]
)

In addition, you can refer the method in the following links to handle with incorrect total values on the matrix visual...

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

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

2 REPLIES 2
johndha
Frequent Visitor

Thank you so much, That helped alot

v-yiruan-msft
Community Support
Community Support

Hi @johndha ,

You can create another new measure as below base on the current measure [Demand_Days_of_task_in_period] and apply the new measure onto the Card visual...

Measure =
SUMX (
    GROUPBY ( 'Assignments', 'Assignments'[Employee Name], 'Assignments'[TaskName] ),
    [Demand_Days_of_task_in_period]
)

In addition, you can refer the method in the following links to handle with incorrect total values on the matrix visual...

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

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.

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