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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
0xygen27
Advocate II
Advocate II

How to subtract a group of variables from a column

Dear Community, 

 

I am a new user and working on my first dashboard in Power BI. The file I got has data in weekly frequentcy from different departments, these are all sorted on date. One column is the amount of employees from the department on that specific date, I want to calculate what the total amount of workers is on that date and how many percentage of the total employees are working for that department.

 

The table is like this 

Column A(Date) Column B(Departement) Column C (Profiles,which is how many people there are) Column D (Variable X)

19-02-2017         Department A                   8

19-02-2017         Department B                   9

19-02-2017         Department C                   293

26-02-2017         Department A                  15

26-02-2017         Department B                   8

26-02-2017         Department C                   300

 

So I want to calculate  

Total Employees on that date 

Percentage of employees working for that department on that date 

 

Thanks in advance,

 

0xygen27

 

6 REPLIES 6
CheenuSing
Community Champion
Community Champion

Hi @0xygen27

 

Try the following

 

1. Create a measure called TotalByDate

   TotalByDate = Calculate(sum(Table3[ColumnC]), ALLEXCEPT(Table3,Table3[ColumnA]))

2. Createa measure called %toTotal

   %toTotal = Divide(sum(Table3[ColumnC]),[TotalByDate])

 

Replace all Table3 by your tablename. Sample output with the data provided by you.

 

Capture.GIF 

 

If this resolves your issue, please accept it as a solution and also give KUDOS.

 

Cheers

 

CheenuSing

 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
v-shex-msft
Community Support
Community Support

Hi @0xygen27,

 

You can try to use below formula which about calculate the running total:

 

Measure:

 

Running total=
var currDepart= LASTNONBLANK(Table[Department],[Department])
return
SUMX(FILTER(ALLSELECTED(Table),Table[Department]=currDepart&&Table[Date]<=MAX(Table[Date])),[Profiles])

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Power BI gives me the return: The MAX function only accepts a column reference as an argument.

Hi @0xygen27,

 

>>Power BI gives me the return: The MAX function only accepts a column reference as an argument.

Can you share us your formula?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Running total = var currDepart= LASTNONBLANK('database'[Profiel],'database')
return
SUMX(FILTER(ALLSELECTED('database'),'database'[Profiel]
=currDepart&&RELATEDTABLE(Datedimension)<=MAX(Datedimension)),'database'[Profiel])

 

 

Hi @0xygen27,

 

>>RELATEDTABLE(Datedimension)<=MAX(Datedimension)

You need to specify a column from that table, max function not works on table.

 

In addition, if your visual has created from different table, it will be help if you share some sample data.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.