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
pasno
Helper II
Helper II

Use a calculated measure on another measure

Hello guys,

I need your help to proceed smoothly in my dashboard please!

 

I'm creating a new measure to use it inside my dashboard, and I'm calculating a dynamic date to select the count the right values I need.

 

Please have a look at hte following measure. It works correctly when i select the Date range using manual numbers to set year, month and day.

Result = CALCULATE(DISTINCTCOUNT('CostiRicaviTotale'[IDSpedizioneUnivoco]); ALL('MisurePersonalizzate'[ColonnaKW-1]); Calendario[Data]<=DATE(2021; 1; 31))

 

But I want to use a dynamic date range, so for example I made the following measure:

YearToUse = YEAR(TODAY())

 

Now, I want to insert my measure (YearToUse) inside the other measure (Result), to have a dynamic year value.

If I set the following code, I always get an error:

Result = CALCULATE(DISTINCTCOUNT('CostiRicaviTotale'[IDSpedizioneUnivoco]); ALL('MisurePersonalizzate'[ColonnaKW-1]); Calendario[Data]<=DATE(YearToUse; 1; 31))

 

Any help will be very appreciated, thank you in advance 🙂

 

 

 

 

 

 

1 ACCEPTED SOLUTION
VijayP
Super User
Super User

@pasno 

You have Created a mesure YeartoUse separately and now you want to include in the measure

Instead of creating a separate mesaure you can create that measure by using Variables

VAR yeartouse = your Measure

and using RETURN syntax 

you can use the Variance yeartouse in your final formula




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


View solution in original post

4 REPLIES 4
VijayP
Super User
Super User

@pasno 

You have Created a mesure YeartoUse separately and now you want to include in the measure

Instead of creating a separate mesaure you can create that measure by using Variables

VAR yeartouse = your Measure

and using RETURN syntax 

you can use the Variance yeartouse in your final formula




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Top, got it!

Thank you again!!!

VijayP
Super User
Super User

@pasno 

you can use VAR (variable) within the Measure 

https://docs.microsoft.com/en-us/power-bi/guidance/dax-variables

Please let me know if any further help required!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Hello @VijayP 

Thank  you for the answer.

I had a look at the link, but I don't understand how can I convert my measure with VAR..

 

Result = CALCULATE(DISTINCTCOUNT('CostiRicaviTotale'[IDSpedizioneUnivoco]); ALL('MisurePersonalizzate'[ColonnaKW-1]); Calendario[Data]<=DATE(YearToUse; 1; 31))

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.