Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.