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

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. 

key_to_0-1665138755601.png

 

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? 
 
Thanks a lot in advance!
1 ACCEPTED SOLUTION
key_to
Advocate I
Advocate I

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: 

key_to_0-1665385154970.png

 

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

View solution in original post

3 REPLIES 3
key_to
Advocate I
Advocate I

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: 

key_to_0-1665385154970.png

 

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

v-yinliw-msft
Community Support
Community Support

Hi @key_to ,

 

Could you please tell me more about your purpose of converting numbers to variables?

What do you want to calculate?

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

vyinliwmsft_0-1665371726944.png

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.

 

visheshjain
Solution Supplier
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.

 

Please provide us more information along with a sample PBIX file.

 

Thank you,

Vishesh Jain

Did I answer your question?
If yes, then please mark my post as a solution!

Thank you,
Vishesh Jain

Proud to be a Super User!



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.