Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Kumarcy
Helper II
Helper II

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
v-gizhi-msft
Community Support
Community Support

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
v-gizhi-msft
Community Support
Community Support

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

amitchandak
Super User
Super User

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.