Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

help with formulating calculate filtered with variable dax

Hi,

 

I have a issue that I'm not able to resolve with dates. I have a dimcalendar and workagreement("Työsopimus") table with start and enddate. When I create a relationship, other of the date relations is inactive. I'm having a barchart with line visual and ttrying to show new hires, new hires same period last year and Number of employees YoY%. Visual is not showing correctly because of need to use these two dates.

I'm trying to overcome the problem with breaking the measures in smaller pieces in order to use both enddate and sstartdate relationship to dimCalendar table but I don't know how to resolve the following as the variables gives an error multiple columns cannot be converted to a scalar value.


NOE =
var wagreementStartDate = FILTER(DimCalendar,DimCalendar[Date] <= TODAY()))
var wagreementEndDate = CALCULATE(FILTER(DimCalendar,DimCalendar[Date] >=TODAY()), 
USERELATIONSHIP('Työsopimus'[enddate],DimCalendar[Date]))

RETURN
 CALCULATE( COUNTROWS('Työsopimus'), wagreementStartDatewagreementEndDate)
  • PC2790's avatar
    PC2790
    4 years ago

    Please refer attached my sample file where all the required calculations are there.

    You can alos refer the blog which might cater to your requirement 

     

9 Replies

  • PC2790's avatar
    PC2790
    Icon for Community Champion rankCommunity Champion

    The code is incorrectly used.

    Can you give a sample of your data to understand how it looks like and also the expected result?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi PC2790 
      sample of workagreement table: https://docs.google.com/spreadsheets/d/1Fi-bRL0TalSatqG2Fs_coCtJbDwShDX4oiMKwDT7Mo8/edit?usp=sharing

      Calculations: New hires (new hires this year) New hires same period last year and NOE YoY% 
      - NOE
      - NOE last year
      - NOE var = [NOE] - [NOE last year]
      from those measures I calculate Noe YoY%: Noe YoY% = [NOE last year] - [NOE var]


      Expected results are:
      New hires = 8
      new hires same period last year = 3
      NOE = 10
      NOE last year = 4
      NOE var = 6
      NOE YoY% = based on calculations

      • Anonymous's avatar
        Anonymous
        Not applicable

         

      • PC2790's avatar
        PC2790
        Icon for Community Champion rankCommunity Champion
        NOE = 
        CALCULATE(COUNTROWS(EmployeeTable),FILTER(EmployeeTable,(EmployeeTable[enddate] == BLANK() || EmployeeTable[enddate] >=TODAY()) && EmployeeTable[startdate] <= TODAY()))

        Here you go.

        This gives an outcoe of 10 as expected.