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
ajohn1
Advocate I
Advocate I

Column value as Measure value

Lets say my date column has the value of '2018-12-27'.  How can I get my measure (not column) to equal exacly '2018-12-27'. Or how can I get my measure to equal just the year '2018'.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@ajohn1 how about calculate number of days by doing a countdistinct on number of dates in the date table for a year

 

for example

 

Customer Count =

var numdays = CALCULATE(distinctcount([date]), allexcept(query1,year(query1[targetdate]))

return sum(Query1[Customer Served])/ numdays

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@ajohn1 can you give an exact scenario when you are trying to do this?

Calculated column Total_Days_in_Year  =  Date(year(Query1[TargetDate]),12,31)-DATE(year(Query1[TargetDate]),1,1)+1. Total_Days_in_Year can either be 365 or 366(leap year). This returns the right value.

 

I have a calculated measure ‘Customer Count = sum(Query1[Customer Served]) / ( ??? *4)’. I would like to replace ??? with Total_Days_in_Year. Power BI will only let me use Total_Days_in_Year if it is aggregated.

 

So what can I do here?

Anonymous
Not applicable

@ajohn1 how about calculate number of days by doing a countdistinct on number of dates in the date table for a year

 

for example

 

Customer Count =

var numdays = CALCULATE(distinctcount([date]), allexcept(query1,year(query1[targetdate]))

return sum(Query1[Customer Served])/ numdays

Thans so much it worked. Where can I go to learn more things like this?

Anonymous
Not applicable

@ajohn1 i am still learning a lot of this stuff and I am doing it by solving problems on the forum.

 

also could you mark the correct solution as the accepted one?

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.