Forum Discussion

herwet's avatar
herwet
Frequent Visitor
4 years ago

Combining multiple measures into one column chart.

Hi, 

I have an issue I have been struggling with. 

The case is: 

I am making a KPI report and want to measure Gross Profit per region divided by workforce per region in the different sectors.

 

For example, I have following DAX to calculate gross profit in sales in region AMS in 2021: 

GP 2021 AMS = calculate(SUMX('General Measures',[SUM Amount]), FILTER('Fact_Table','Fact_Table'[P&L Level 3] IN {"Product cogs", "Product revenue", "Service COGS", "Services revenue"}), ('Dim_Date'[Year] = "2021" ), (Fact_Table[Region u/ACON] = "AMS"))
 
This is divided into the following DAX to find workforce by AMS: 
Sales AMS 2021 = CALCULATE(sum('Workforce'[Workforce]), 'Workforce'[JC KEY] = "HC2000", 'dim_date'[Year] = "2022", Workforce[Region] = "AMS" ) --> This is later turned into average per month
 
So the question is: By doing this I need to create a significant amount of measures to find gross profit per region in 2021 and 2022, to measure differences. 
However, do someone know if I can write this DAX more efficiently and be able to visualize that data in one column chart? Now I have to use multiple column charts next to each other since it's different data fundament. 
 
Hope this made some sort of sense. Appreciate some help with this 🙂 

 

3 Replies

  • herwet , I will use measure like

     

    Sales AMS 2021 = CALCULATE(sum('Workforce'[Workforce]), 'Workforce'[JC KEY] = "HC2000",, Workforce[Region] = "AMS" , filter( 'dim_date' , 'dim_date'[Year] = max( 'dim_date'[Year]) ) )

     

    example

    //Only year vs Year, not a level below

    This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
    Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

     

    You can also check calculation groups Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0 

  • V-lianl-msft's avatar
    V-lianl-msft
    Community Support

    Hi herwet ,

     

    You need to confirm the current context of your measure If you need to calculate all regions, you should consider adding fields to the visual to affect the context.


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

  • Anonymous's avatar
    Anonymous
    Not applicable

    You can use one Switch-measures in your visual. Within the Switch you can create a reference to your measures.