Forum Discussion

vinoothna9's avatar
vinoothna9
Frequent Visitor
5 years ago
Solved

Relationship/Dax Function

I have a requirement where I have to represent revenue amount in a bar chart and  Fiscal year, Quarter as Slicers.

- Revenue Amount is from Revenue table.

 - Fiscal year, Quarter slicers are from Default Calendar table which is a formulated table created in Power BI.

* Revenue table has a date column Related to Default Calendar's date column ( Many to one Relationship).

 

Here, Fiscal year slicer and Quarter Slicer filters are not Interacting with the Revenue Amount Visual.

I tried making relationship between Fiscal years active and wrote a Dax Function

 

Revenue Amount = Calculate( Sum('Revenue Table'[Revenue]), USERELATIONSHIP ('Default Calendar'[Quarter],'Revenue Table'[Quarter])

 

This way I am able to achieve the interaction but the Revenue amount is giving the total revenue of 2 fiscal years not each seperately, How can I Achieve this ?

 
 
 
  • Hi vinoothna9 ,

    The reason that cause this issue is that you diable the date relationship between two tables so that the fiscal year slicer could not work and the visual will show both fiscal years value based on your initial measure.

    You can modify your measure like this:

    Revenue Amount = 
    CALCULATE (
        SUM ( 'Revenue Table'[Revenue] ),
        FILTER (
            'Revenue Table',
            YEAR ( 'Revenue Table'[Date] )
                = SELECTEDVALUE ( 'Default Calendar'[Fiscal year] )
        ),
        USERELATIONSHIP ( 'Default Calendar'[Quarter], 'Revenue Table'[Quarter] )
    )

    In my sample use the table visual to show the result directly:

    Attached the sample file in the below, hopes to help you.

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

8 Replies

  • vinoothna9 , if date of revenue is joined with date of calendar, why to you need to join Quarter?

    You should able to get fiscal year, Quarter using date table.

    The information you have provided is not making the problem clear to me. Can you please explain with an example.

    Appreciate your Kudos.

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion

    vinoothna9  This should not need any special measures. If the relationship is already there, it will work, but relationship must be on Date column NOT quarter columns. 

     

    Revenue measure should simply look like: 

     Total Revenue = Sum('Revenue Table'[Revenue])

     

    Put that in the revenue visual. Relate Revenue[Date] to Date[Date]. In slicers, use Date[FiscalQuarter] and Date[FiscalYear]

     

    Not sure how you've created the date table and columns? https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

  • vinoothna9's avatar
    vinoothna9
    Frequent Visitor

    Yes It doesn't require any measure if Revenue[date] is related to Date[Date]. For some reason I don't see revenue Amount in the visual when I have Revenue[Date] related to Date[Date]. The slicers are working fine for other tables/columns except Revenue table.

     

  • dobregon's avatar
    dobregon
    Impactful Individual

    Hi vinoothna9 
    Other solution (but not good about optimization) is that you can create a calculated column in the calendar table or in your principal table and take the revenue values

    Revenue = calculate(max(revenuevalue), filter(tablerevenue, tableorigin[date] = tablerevenue[date]))

    And then you can do a measure with the sum of revenue

  • v-yingjl's avatar
    v-yingjl
    Community Support

    Hi vinoothna9 ,

    The reason that cause this issue is that you diable the date relationship between two tables so that the fiscal year slicer could not work and the visual will show both fiscal years value based on your initial measure.

    You can modify your measure like this:

    Revenue Amount = 
    CALCULATE (
        SUM ( 'Revenue Table'[Revenue] ),
        FILTER (
            'Revenue Table',
            YEAR ( 'Revenue Table'[Date] )
                = SELECTEDVALUE ( 'Default Calendar'[Fiscal year] )
        ),
        USERELATIONSHIP ( 'Default Calendar'[Quarter], 'Revenue Table'[Quarter] )
    )

    In my sample use the table visual to show the result directly:

    Attached the sample file in the below, hopes to help you.

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.