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
AbrarBMC
New Member

Measure adding monthly values

I have 5 years of monthly data with the following columns: Date, Total Users, Active users. I tried to calculate active user ratio using a measure. The measure calculates the monthly values correctly, but when I use the date hierarchy and use year only, the measure adds the monthly values instead of recalculating yearly values. Can anyone help?

 

DateTotal UsersActive Users
01/01/2019100002000
02/01/2019110002200
03/01/2019120002600
04/01/2019130002500
05/01/2019140003000
06/01/2019150002700
07/01/2019160004000
08/01/2019170003750
09/01/2019180004250
10/01/2019190004000
11/01/2019200005000
12/01/2019200005000
01/01/2020210005500

 

Sample formula that I was using for the measure: 

Active Users Ratio = Table[Active Users] / Table[Total Users]

1 ACCEPTED SOLUTION

Hi @AbrarBMC 

I think you may build a calculated column except a measure, so when you change the Date to Date Hierachy (Only Year) you will get the sum of the rate.

I build a table like yours to have a test.

1.png

Calculated column:

Column = 'Table1'[Active Users]/'Table1'[Total Users]

Measure:

Active Users Ratio = DIVIDE(SUM('Table1'[Active Users]), SUM('Table1'[Total Users]))

Result:

2.png

We can see the measure's result is correct and the calculated column's result is wrong like yours.

Or you can build two measures to see the result directly.

I add a Year column and Month column in Table2.

Year = YEAR(Table2[Date])
Month = MONTH(Table2[Date])

Measure:

Monthly Active Users Ratio = DIVIDE(SUM(Table2[Active Users]),SUM(Table2[Total Users]))
Yearwise Active Users Ratio = 
var _AU = CALCULATE(SUM(Table2[Active Users]),FILTER(ALL(Table2),Table2[Year]=MAX(Table2[Year])))
var _TU = CALCULATE(SUM(Table2[Total Users]),FILTER(ALL(Table2),Table2[Year]=MAX(Table2[Year])))
return
DIVIDE(_AU,_TU)

Result:

3.png

You can download the pbix file from this link: Measure adding monthly values

For more info to Measure and Calculated column: Calculated Columns vs Measures

 

Best Regards,

Rico Zhou

 

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

5 REPLIES 5
v-rzhou-msft
Community Support
Community Support

Hi @AbrarBMC 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

amitchandak
Super User
Super User

@AbrarBMC ,

Not very clear

try like

AverageX(Summarize(Table, Table[Month-year], "_1" ,sum(Table[Total Users]), "_2" ,sum(Table[Active users])), divide([_2],[_1]))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Greg_Deckler
Super User
Super User

@AbrarBMC Sorry, having trouble following, can you post sample data as text and expected output?

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I have updated my post and added a table and the formula I was using. I want the output to be active user ratio. I want it in two timeframes. Monthly basis and yearwise. Let me know if you need more details.

Hi @AbrarBMC 

I think you may build a calculated column except a measure, so when you change the Date to Date Hierachy (Only Year) you will get the sum of the rate.

I build a table like yours to have a test.

1.png

Calculated column:

Column = 'Table1'[Active Users]/'Table1'[Total Users]

Measure:

Active Users Ratio = DIVIDE(SUM('Table1'[Active Users]), SUM('Table1'[Total Users]))

Result:

2.png

We can see the measure's result is correct and the calculated column's result is wrong like yours.

Or you can build two measures to see the result directly.

I add a Year column and Month column in Table2.

Year = YEAR(Table2[Date])
Month = MONTH(Table2[Date])

Measure:

Monthly Active Users Ratio = DIVIDE(SUM(Table2[Active Users]),SUM(Table2[Total Users]))
Yearwise Active Users Ratio = 
var _AU = CALCULATE(SUM(Table2[Active Users]),FILTER(ALL(Table2),Table2[Year]=MAX(Table2[Year])))
var _TU = CALCULATE(SUM(Table2[Total Users]),FILTER(ALL(Table2),Table2[Year]=MAX(Table2[Year])))
return
DIVIDE(_AU,_TU)

Result:

3.png

You can download the pbix file from this link: Measure adding monthly values

For more info to Measure and Calculated column: Calculated Columns vs Measures

 

Best Regards,

Rico Zhou

 

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.