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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Mikazuki
Frequent Visitor

Previous years sum by year and current year sum by quarter in the same clustered column chart

Hello there,

 

suppose I have a dataset like:

FruitTime
Apple2021/01/23
Apple2022/05/23
Pear2023/01/01
Watermelon2021/01/26
Apple2022/01/26
Pear2022/03/26
Watermelon2023/03/26
Pear2023/06/26
Apple2023/08/26
Pear2023/12/26

 

Is it possible that I can have a clustered column chart like this to show the count of fruit by year if is before 2023 and quarter if is in 2023(Ignore the numbers lol):

Mikazuki_0-1681109587146.png

 

Thanks for your help!!!

 

1 ACCEPTED SOLUTION
PawarNovil
Frequent Visitor

Hi @Mikazuki ,

 

Please try below steps- 

1. create a KPI grouping table-

KPIGrouping = DATATABLE( "KPI", STRING,
                        "Sort", INTEGER,
                         { {"2021", 1 },
                          {"2022",2},
                          {"YTD2023",3},
                          {"1st Quarter",4},
                          {"2nd Quarter",5},
                          {"3rd Quarter",6},
                          {"4th Quarter", 7}
                          }
)
------------------------------------------------------
2. create measures for your individual KPI's (2021, 2022, YTD2023,....) based on your required result and filter context.
for example -
Count2021 = 
CALCULATE(COUNTA(FruitTable[Fruit]),  year(FruitTable[Date])=2021)
Count2022=CALCULATE(DISTINCTCOUNT(FruitTable[Fruit]), FILTER(FruitTable, year(FruitTable[Date])=2022))
--------------------------------------------------------
3.  create visual and use KPI  from KPIGrouping table and cretae a measure as below
-----------------------
KPI Grouping Cluster Chart =
var selectedKPI=SELECTEDVALUE(KPIGrouping[KPI],"2021")
var currentkpi = switch (
selectedKPI,
"2021", [Count2021],
"2022",[Count2022],
"YTD2023",[Count2023YTD],
 "1st Quarter",2,  // Put your 1st Quarter measure name in place of 2
"2nd Quarter",1, // Put your 2nd Quarter measure name in place of 1
"3rd Quarter",1,  // Put your 3rd Quarter measure name in place of 1
"4th Quarter", 1, // Put your 4th Quarter measure name in place of 1
blank()
)
return
currentkpi
---------------------------------------------------------------------------------------------
PawarNovil_0-1681212568877.png

 

 

--------------------------------------------------------------------------------------------------------------------

 

Regards,

Novil

If I answer your question, please mark my post as a solution.

View solution in original post

3 REPLIES 3
PawarNovil
Frequent Visitor

Hi @Mikazuki ,

 

Please try below steps- 

1. create a KPI grouping table-

KPIGrouping = DATATABLE( "KPI", STRING,
                        "Sort", INTEGER,
                         { {"2021", 1 },
                          {"2022",2},
                          {"YTD2023",3},
                          {"1st Quarter",4},
                          {"2nd Quarter",5},
                          {"3rd Quarter",6},
                          {"4th Quarter", 7}
                          }
)
------------------------------------------------------
2. create measures for your individual KPI's (2021, 2022, YTD2023,....) based on your required result and filter context.
for example -
Count2021 = 
CALCULATE(COUNTA(FruitTable[Fruit]),  year(FruitTable[Date])=2021)
Count2022=CALCULATE(DISTINCTCOUNT(FruitTable[Fruit]), FILTER(FruitTable, year(FruitTable[Date])=2022))
--------------------------------------------------------
3.  create visual and use KPI  from KPIGrouping table and cretae a measure as below
-----------------------
KPI Grouping Cluster Chart =
var selectedKPI=SELECTEDVALUE(KPIGrouping[KPI],"2021")
var currentkpi = switch (
selectedKPI,
"2021", [Count2021],
"2022",[Count2022],
"YTD2023",[Count2023YTD],
 "1st Quarter",2,  // Put your 1st Quarter measure name in place of 2
"2nd Quarter",1, // Put your 2nd Quarter measure name in place of 1
"3rd Quarter",1,  // Put your 3rd Quarter measure name in place of 1
"4th Quarter", 1, // Put your 4th Quarter measure name in place of 1
blank()
)
return
currentkpi
---------------------------------------------------------------------------------------------
PawarNovil_0-1681212568877.png

 

 

--------------------------------------------------------------------------------------------------------------------

 

Regards,

Novil

If I answer your question, please mark my post as a solution.

Mikazuki
Frequent Visitor

Dear Pat,

 

I see the link that you attached but I still cannot get the data like 2023YTD as an individual part from the graph, could you please help me with the dax function with the sample data that I listed before? Thanks.

ppm1
Solution Sage
Solution Sage

You can do that with calculation groups.

Introducing Calculation Groups - SQLBI

 

Pat

Microsoft Employee

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.