cancel
Showing results 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.

## help creating a variable

Hello!

I have a simple table with 'end of year' date, org unit and number of employees - see screenshot. I would like to convert all the numbers in the table below into variables so that I can use them in other calculations like turnover or growth.

I created a dimension table with all the org units that connects the "orgenhet" in this table to the main table.  This is because I wanted to avoid to have to created a variable per org unit. I tried something like this:

.LY Antall Ansatte =
VAR YEdate =
YEAR (TODAY())-1
VAR YEansatt =
SUMX(FactYearEnd[EoY Antall ansatte])
FILTER (
FactYearEnd,
(
YEAR('FactYearEnd'[Date])=YEdate
)
))

RETURN
YEansatt

I think the logic might work, but the formula is wrong. Anyone who can help me?

1 ACCEPTED SOLUTION

Hi and thanks to you both for putting me on a right path!

I was probably just thinking to complicated.  I wanted to be able to refer to the number from the table through variable and I think I achieved it simply with the calculate function:

This looks correctly when testing. Now it remains to see whether I get the right results in my calculation of turnover and growth 🙂

3 REPLIES 3

Hi and thanks to you both for putting me on a right path!

I was probably just thinking to complicated.  I wanted to be able to refer to the number from the table through variable and I think I achieved it simply with the calculate function:

This looks correctly when testing. Now it remains to see whether I get the right results in my calculation of turnover and growth 🙂

Community Support

Hi @key_to ,

What do you want to calculate?

But the function SUMX needs two parameters and the first parameter needs to be a table:

SUMX function (DAX) - DAX | Microsoft Learn

You can refer this documentation.

Hope this helps you.

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Solution Supplier

Hi @key_to,

Not sure what are you trying to do, but why do you need a variable for each organization?!

If you have created a dimension table, then create a relationship between the fact and the dimension table and use the organization as a slicer/field on your report.

If you are trying to get the value of the previous year of the same organization then you can use MAX() function over the dates column.

Thank you,

Vishesh Jain

If yes, then please mark my post as a solution!

Thank you,
Vishesh Jain

Proud to be a Super User!

Announcements

#### 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

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors