cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

need help with dax

Hi,

I have a static table(table1) called date contain Month, Year, Quarter and then i would like to create a calculated column using that static table 

 

DAX:

IF(Hasonevalue(table1), switch(values(table1), "Month",  Year([Date]) & " " & Month([Date]), "Year", Year([Date]), "Quarter", Year([Date]) & " " & Quarter([Date]))

 

When user select month  then the calculated column should show Yearmonth, If user select Quarter then Year Quarter.

 

Table1 
Month 
Year 
Quarter 
  
If user select Month
Output 
Calculated column 
2020 01 
2020 02 
2020 03 
  

 

Then i will use that calculated column as slicer.

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: need help with dax

Hi,

 

Please try to create a calculated table:

Table 3 = 
UNION (
    SELECTCOLUMNS (
        'Table 2',
        "Date", FORMAT ( 'Table 2'[Date], "YYYY MM" ),
        "Group", "Month"
    ),
    SELECTCOLUMNS (
        'Table 2',
        "Date", FORMAT ( 'Table 2'[Date], "YYYY" ),
        "Group", "Year"
    ),
    SELECTCOLUMNS (
        'Table 2',
        "Date", FORMAT ( 'Table 2'[Date], "YYYY q" ),
        "Group", "Quarter"
    )
)

Choose this table's [Group] as one slicer for end user and this table's [Date] as another slicer for you to choose.

The result shows:

10.PNG

See my attached pbix file.

 

Best Regards,

Giotto

View solution in original post

2 REPLIES 2
Highlighted
Super User IV
Super User IV

Re: need help with dax

@Kumarcy , Check if this can help, how to use the slicer to have different formulas

https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Community Support
Community Support

Re: need help with dax

Hi,

 

Please try to create a calculated table:

Table 3 = 
UNION (
    SELECTCOLUMNS (
        'Table 2',
        "Date", FORMAT ( 'Table 2'[Date], "YYYY MM" ),
        "Group", "Month"
    ),
    SELECTCOLUMNS (
        'Table 2',
        "Date", FORMAT ( 'Table 2'[Date], "YYYY" ),
        "Group", "Year"
    ),
    SELECTCOLUMNS (
        'Table 2',
        "Date", FORMAT ( 'Table 2'[Date], "YYYY q" ),
        "Group", "Quarter"
    )
)

Choose this table's [Group] as one slicer for end user and this table's [Date] as another slicer for you to choose.

The result shows:

10.PNG

See my attached pbix file.

 

Best Regards,

Giotto

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Top Solution Authors
Top Kudoed Authors