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

Lookup and sum with criteria

I am an absolute DAX beginner and am looking for a solution to the following problem:

In the following table there are companies, departments, date (monthly period) and a value.

Now I am looking for a way to create a DAX Querry which sums up all companies for a specific department (100 in the example).
This in the current year and in the last year. A date table is already created.

 

thebeginner1204_0-1664959891615.png

 

Questions:

Which is the best variant for this case?
Calculate(sum(Lookupvlaue... or Calculte(sum(filter....

 

Are there any examples for this case?

 

Thanks for help

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi,

I am not sure about how your expected outcome looks like, but in case if you want to create a table visualization, please check the attached file and the below picture.

 

Jihwan_Kim_0-1664962782727.png

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim thanks for the answer. the table would clearly be the easiest. but I need the values in a measure for other visuals and further calculations.

Hi,

Thank you for your feedback.

Please check the below picture and the attached pbix file.

I added a measure.

 

Jihwan_Kim_0-1664966738223.png

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thank you very much for the file and the answer.
The aim is to have all values in 2 periods in different measures.

 

Measure 1: Sum of all companies in division 100 from January 2021 (last year/month dynamically using Date column).

 

thebeginner1204_1-1664967678217.png

 

Measure 2: Sum of all companies in derivation 100 (January 2022) from current year (last year/month dynamically using Date column)

 

thebeginner1204_0-1664967652359.png

 

The correct data includes further departments (e.g. 200 etc.).

The calculations in this case are liquid assets (from a balance sheet).
Finally, I need the total per department in a period (independent of the company), in individual measures which I can then use further (e.g. balance sheet ratios, liquidity level etc).

Hi,

Thank you for your feedback.

Could you please share your sample pbix file's link? I think only seeing the excel file's screenshot makes me a little bit confuse to create a solution.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim 

clear here in the link for download: https://xfl.jp/MexV9p 
The structure of the data does not differ much from the demo data in Excel.

 

Here is another explanation:
These are raw data from a financial programme. For this, departments (cost centres of departments) would have to be processed across several companies.

 

To do this, I have to sum up individual cost centres (departments) across companies (Company column).

Department (cost centre) 100 = Cash and cash equivalents
Department (cost centre) 130 = Inventories

 

In the end, the totals are then put in relation (%) to each other.
For example: 100 (Sum uf all Deparemnets) / 130 (Sum uf all Deparemnets).

 

The difficulty, however, lies in the period (history). In order to display this on a monthly basis (e.g. on a line chart), I have to create measures in advance where I can then calculate the ratios. The ratios are then combined (e.g. with a target value) in the line chart.

 

In the meantime I have tried and tried with "lookupvalue" and there it seems to be limited because I need several criteria (this year -1 and department 100 for example).

 

thx for help

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.

Top Solution Authors